Multi-Form ASP.NET 2.0 Page

Nate Bross

Well-known member
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
I have a simple project, with a master page that has a <form runat="server"> in it, all content pages are inside the open and close form tags. I have some stuff in the master page that needs the <form> (TreeView for navigation) and I have some stuff in the content pages that need the <form> (Calander Control for date picking) Everything was working good, until i tried to impliment google adsense search, it requires the following code to be on the search page.


The issue is that this code here requires a form with a specific method (get) and action (search.aspx).

This code below doesnt actually ever do the get when I press the button, because the <form runat=server> seems to mess it up. If I take out the <form runat=server> the code below works, but breaks all of my other C# code behind.

Anyone have any ideas how to make both work at once?
Code:
<form method="get" action="Search.aspx" target="_top">
    <table border="0" bgcolor="#000000">
        <tr>
            <td nowrap="nowrap" valign="top" align="left" height="32">

            </td>
            <td nowrap="nowrap">
                <input type="hidden" name="domains" value="theparadox.zone13.net"></input>
                <label for="sbi" style="display: none">Enter your search terms</label>
                <input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input>
                <label for="sbb" style="display: none">Submit search form</label>
                <input type="submit" name="sa" value="Google Search" id="sbb"></input>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td nowrap="nowrap">
                <table>
                    <tr>
                        <td>
                            <input type="radio" name="sitesearch" value="" id="ss0"></input>
                            <label for="ss0" title="Search the Web"><font size="-1" color="white">Web</font></label></td>
                        <td>
                        <input type="radio" name="sitesearch" value="theparadox.zone13.net" checked id="ss1"></input>
                        <label for="ss1" title="Search theparadox.zone13.net"><font size="-1" color="white">theparadox.zone13.net</font></label></td>
                    </tr>
                </table>
                <input type="hidden" name="client" value="xxxxxxxxxxxx"></input>
                <input type="hidden" name="forid" value="1"></input>
                <input type="hidden" name="ie" value="ISO-8859-1"></input>
                <input type="hidden" name="oe" value="ISO-8859-1"></input>
                <input type="hidden" name="cof" value="GALT:#3399FF;GL:1;DIV:#666666;VLC:FFFFFF;AH:center;BGC:000000;LBGC:FFFF00;ALC:FFFFFF;LC:FFFFFF;T:CCCCCC;GFNT:FFFFFF;GIMP:FFFFFF;FORID:11"></input>
                <input type="hidden" name="hl" value="en"></input>
            </td>
        </tr>
    </table>
</form>
 
The page can only contain one visible server-side form.
So if you can put the Google form outside the main page form, then it should be working fine.

Or you may add the onclick handler to the submit button to submit the specific form. In that case you should also add name or id attribute to that Google form. If that dont work, change that input type to button instead of submit.


Code:
<form name="googleForm" method="get" action="Search.aspx" target="_top">
...
<input type="submit" name="sa" value="Google Search" id="sbb" OnClick="document.forms[googleForm].submit();"></input>
...

Give it a try, it should work :)
 
Back
Top