Google Search Code on ASP.NET Home Page

I am trying to put the following google generated code into the home 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;lang=en"></script>

      

The problem I believe is related to the form tags. I tried to put this code in a custom control and embed it in the master page, but so far no success ...

+1


source to share


4 answers


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



+2


source


Do you have a chance that the "runat = server form" is wrapping around your custom control?
This will cause a problem.



+2


source


ASP.NET likes to cover the whole page with a form tag, and you cannot insert form tags ... So move it outside of <form runat = "Server"> and you should be fine.

+2


source


+2


source







All Articles