Adding a new User Control gives page can have only one server-side Form tag

A

AlecL

I have a page that has about 5 or 6 user controls ranging from hearders
to footers to ad space but when I add a new user control which is a
form it gives me the exception "page can have only one server-side Form
tag" error. Here is the brief code that I am adding to the code:

on top:
<%@ Register TagPrefix="uc" TagName="CareerStats"
Src="/Controls/CareerStats.ascx" %>

and the div where I added the control:

<asp:panel ID="pnlSecondaryNav" Runat="server">
<uc:SiteTools id="SiteTools" runat="server"></uc:SiteTools>
</asp:panel>

The code inside the UC(if it is relevent) looks like this:


Sub btnSubmit_click()
Session.Item("txtTourName")=txtTournamentName.text
Session.Item("txtTourType")=txtTournamentType.selectedItem.text
Session.Item("txtTourYear")=txtYear.selectedItem.text
Response.redirect("/all_arnie/career.aspx")

End Sub
</script>
<tr>
<td class="topleft" valign="top">
<form runat="server">
<table id="CareerTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="PADDING-LEFT:5px; WIDTH:217px">
<h3>Career Stats</h3>
<label for="txtTournament">Tournament:</label><br>
<asp:textbox width="120px" id="txtTournamentName" runat="server"
/><br>
<label for="txtTournamentType">Select Tour Type:</label><br>
<asp:dropdownlist id="txtTournamentType" runat="server"
Width="128px">
<asp:listitem value="1">PGA</asp:listitem>
<asp:listitem value="2">Non-PGA</asp:listitem>
<asp:listitem value="3">Senior</asp:listitem>
<asp:listitem value="4">Non-Senior</asp:listitem>
</asp:dropdownlist><br>
<label for="txtTournament">Tournament Year:</label><br>
<asp:dropdownlist id="txtYear" runat="server" Width="152px">
<asp:listitem value="">Please Select</asp:listitem>
</asp:dropdownlist><br><br>
<br>
<asp:Button id="btnSubmit" runat="server" Text="Submit"></asp:Button>

<br>
<br>
</td>
</tr>
</table>
</form>

Please Help
 
J

Jurgen

Hi,

Does the page on which you add the control already have a form with
runat="server"?
If so, and you add a control to that form which also has a form with
runat="server", you are nesting server forms, which is nog allowed.

If the page already has the form, you can leave the form declaration from
your control, as its contents will be rendered inside the form on the
page...

Hope this helps,
Jurgen
 
A

AlecL

Thanks Jurgen! However, if I do that and remove the form tag from the
control it gives me the error that <asp:textbox> tag on the control
needs to be within a form that's run on server. Is there a way around
it?

Thanks - Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top