Google custom search code is provided as a form tag. However, only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element).

+5  A: 

You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat="server") form tags.

You can implement two form tags (or more) as long as only one has the runat="server" attribute and one is not contained in the other. Example:

<form action="" id="cse-search-box"> ... </form>
<form runat="server" id="aspNetform"> ... </form>
Chris Pebble
+2  A: 

You may be able to have multiple form tags, but note that they cannot be nested. You'll run into all kinds of weirdness in that scenario (e.g., I've seen cases where the opening tag for the nested form apparently gets ignored and then its closing tag winds up closing the "parent" form out).

Eric Longman

You could use Javascript:

<input name="Query" type="text" class="searchField" id="Query" value="Search" size="15" onfocus="if(this.value == 'Search') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Search'; }" onkeydown="var event = event || window.event; var key = event.which || event.keyCode; if(key==13)'' + getElementById('Query').value ); " /><input name="" type="button" class="searchButton" value="go" onclick="'' + getElementById('Query').value );" />
Timothy Lee Russell
+1  A: 

You'll need to remove the form tag and use javascript send the query. Have a look at

I have included the before and after code as well. So you can see what I've done to integrate it with blogengine .net.

Thank you, it is working.
That doeesn't seem to be a good solution. What about users that have javascript disabled?
Shea Daniels
If you can separate the 2 form tags then all is good. Otherwise ....Actually, I wonder what's the percentage of people who disables javascript these days ...
I think that's not really a worry these days

try this approach:

kindly notice it has some issues working on Opera, Safari & Chrome, after doing that just make sure it works as it should for these browsers.