472,143 Members | 1,143 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

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

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.sele ctedItem.text
Session.Item("txtTourYear")=txtYear.selectedItem.t ext
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

Jan 2 '07 #1
2 1782
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
"AlecL" <sa********@hotmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
>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.sele ctedItem.text
Session.Item("txtTourYear")=txtYear.selectedItem.t ext
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

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

Thanks - Al
Jurgen wrote:
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
"AlecL" <sa********@hotmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
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.sele ctedItem.text
Session.Item("txtTourYear")=txtYear.selectedItem.t ext
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
Jan 2 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jim Heavey | last post: by
reply views Thread by Chris Davoli | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.