views:

1477

answers:

5

I'm trying to put the following Google generated search box code into a Master page on a site:

<form action="http://www.google.com/cse" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="partner-pub-xxxxxxxxxx:u3qsil-l6ut" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
    <input type="text" name="q" size="31" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;amp;lang=en"&gt;&lt;/script&gt;

The problem, I believe, is something to do with the form tags. I've tried putting this code inside a user control and embedding that in the master page but no luck yet...

+2  A: 

Do you by any chance have a "form runat=server" wrapping around where your user control is being placed?
That would cause a problem.

seanb
+2  A: 

ASP.NET likes to enclose the entire page with a Form tag, and you can't nest form tags...So move it outside of the <form runat="Server"> tag and you'll be fine.

FlySwat
+2  A: 

This article can help you:

Using Google Co-op's Custom Search Engine on ASP .NET

CMS
+1  A: 

Alternatively, you could use javascript: http://dotnetslackers.com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx

Bryan Denny
A: 

Read through this article to understand the form tag error. The article walks you through with all the steps of implementing google search box with asp.net master pages: http://am22tech.com/s/22/Blogs/post/2010/05/26/How-can-I-add-Google-search-box-to-my-website-on-master-page-with-aspnet.aspx

Anil