0

I am designing website which keeps tracks of many products.I want to show a general search box in my home page as a user may enter a product name and information about that product is displayed.

code:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="home.aspx.cs" Inherits="home" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


    <table width="100%" height="271" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" align="center"><h3>Categories</h3></td>
    <td width="33%">    
      <form name="f1" method="get" action="search.aspx">
        <input name="t1" type="text" class="input" placeholder=" Search by shop name" >
        <input id="Submit1" type="submit" class="btn" value="Go" >        
        </form>   
        </td>
  </tr>
  <tr>
</asp:content>

But submit button does nothing when clicked.This logic worked good in my other Php and Jsp web applications.Is this a .net issue or am I missing something ?

user2125727
  • 173
  • 3
  • 4
  • 15

2 Answers2

0
<input id="Submit1" type="submit" runat="server" class="btn" value="Go" >

add runat="server" in ur button tag and check it .
Shanrajesh
  • 26
  • 4
0

You can't nest <form> tag in Asp.Net page. Actually if you are using Master page in Asp.Net, then master page already defines a <form> tag. But if you will add another inside content page then it will not work.

So you have 2 options:

  1. Remove the Master page and Content page, use simple web page having all tags in one place.
  2. Remove the <form> tag from Content page and do the action in Master page.

You can refer to this StackOverflow question for more details.

A page can have only one server-side Form tag

Form Elements in ASP.NET Master Pages and Content Pages

Community
  • 1
  • 1
Santosh Panda
  • 7,235
  • 8
  • 43
  • 56
  • 1st option is not possible as I am nearing to end of project.I tried option no 2 and it shows error as following: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. – user2125727 Mar 04 '14 at 07:43