An asp.net page or master page contains a form tag and Google custom search box code also contains a form tag. Because a single page cannot contain more than one form tag, the search box won't work on asp.net page directly. To resolve this issue, we can create a new separate HTML page and place the Google Search box on this page instead of an asp.net page (including master page). The html file must be in the following format (as shown in
http://bettereducation.com.au/customSearch.htm):
Code:<html xmlns="http://www.w3.org/1999/xhtml">
<body style="margin-top:0px;padding-top:0px;">
<form action="http://bettereducation.com.au/searchResults.htm" id="cse-search-box" target="_top">
<div>
<input type="hidden" name="cx" value="partner-pub-<partner publisher code>" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="Go" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>
</body>
</html>
The second step is to paste the code for search results page (eg.http://bettereducation.com.au/searchResults.htm). This page can be an html or asp.net page.
Then just add the following iframe code on the asp.net page or master page. Then it's done.
Code:<iframe id="IFGoogleSearch" src= "http://bettereducation.com.au/customSearch.htm"
frameborder="0" scrolling="no"
style="padding-top:0px; height: 29px;width:400px; margin-top: 0px;">
</iframe>