By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.