473,834 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="Career Stats"
Src="/Controls/CareerStats.asc x" %>

and the div where I added the control:

<asp:Panel ID="pnlSecondar yNav" 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("t xtTourName")=tx tTournamentName .text
Session.Item("t xtTourType")=tx tTournamentType .selectedItem.t ext
Session.Item("t xtTourYear")=tx tYear.selectedI tem.text
Response.redire ct("/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="txtTournam ent">Tournament :</label><br>
<asp:textbox width="120px" id="txtTourname ntName" runat="server"
/><br>
<label for="txtTournam entType">Select Tour Type:</label><br>
<asp:dropdownli st id="txtTourname ntType" runat="server"
Width="128px">
<asp:listitem value="1">PGA</asp:listitem>
<asp:listitem value="2">Non-PGA</asp:listitem>
<asp:listitem value="3">Senio r</asp:listitem>
<asp:listitem value="4">Non-Senior</asp:listitem>
</asp:dropdownlis t><br>
<label for="txtTournam ent">Tournamen t Year:</label><br>
<asp:dropdownli st id="txtYear" runat="server" Width="152px">
<asp:listitem value="">Please Select</asp:listitem>
</asp:dropdownlis t><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 1887
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********@hot mail.comwrote in message
news:11******** **************@ 42g2000cwt.goog legroups.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="Career Stats"
Src="/Controls/CareerStats.asc x" %>

and the div where I added the control:

<asp:Panel ID="pnlSecondar yNav" 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("t xtTourName")=tx tTournamentName .text
Session.Item("t xtTourType")=tx tTournamentType .selectedItem.t ext
Session.Item("t xtTourYear")=tx tYear.selectedI tem.text
Response.redire ct("/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="txtTournam ent">Tournament :</label><br>
<asp:textbox width="120px" id="txtTourname ntName" runat="server"
/><br>
<label for="txtTournam entType">Select Tour Type:</label><br>
<asp:dropdownli st id="txtTourname ntType" runat="server"
Width="128px">
<asp:listitem value="1">PGA</asp:listitem>
<asp:listitem value="2">Non-PGA</asp:listitem>
<asp:listitem value="3">Senio r</asp:listitem>
<asp:listitem value="4">Non-Senior</asp:listitem>
</asp:dropdownlis t><br>
<label for="txtTournam ent">Tournamen t Year:</label><br>
<asp:dropdownli st id="txtYear" runat="server" Width="152px">
<asp:listitem value="">Please Select</asp:listitem>
</asp:dropdownlis t><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:textboxt ag 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********@hot mail.comwrote in message
news:11******** **************@ 42g2000cwt.goog legroups.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="Career Stats"
Src="/Controls/CareerStats.asc x" %>

and the div where I added the control:

<asp:Panel ID="pnlSecondar yNav" 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("t xtTourName")=tx tTournamentName .text
Session.Item("t xtTourType")=tx tTournamentType .selectedItem.t ext
Session.Item("t xtTourYear")=tx tYear.selectedI tem.text
Response.redire ct("/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="txtTournam ent">Tournament :</label><br>
<asp:textbox width="120px" id="txtTourname ntName" runat="server"
/><br>
<label for="txtTournam entType">Select Tour Type:</label><br>
<asp:dropdownli st id="txtTourname ntType" runat="server"
Width="128px">
<asp:listitem value="1">PGA</asp:listitem>
<asp:listitem value="2">Non-PGA</asp:listitem>
<asp:listitem value="3">Senio r</asp:listitem>
<asp:listitem value="4">Non-Senior</asp:listitem>
</asp:dropdownlis t><br>
<label for="txtTournam ent">Tournamen t Year:</label><br>
<asp:dropdownli st id="txtYear" runat="server" Width="152px">
<asp:listitem value="">Please Select</asp:listitem>
</asp:dropdownlis t><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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4889
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
4
1516
by: MC D | last post by:
When I dynamically add a control by doing something like dim x as control = Page.LoadControl("myControl.ascx") am I actually loading the control from disk??? I don't really understand why I can't access the class for the user control directly... in other words just say: dim x as new myControl()
4
2465
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item, what do I need to do in order to return the "option value" of the control? Moe !--- returned value of the control
10
2513
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of the functions and I can't find out how to do it. Here is an example of what I do and I get the following Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the...
9
4107
by: Alan Silver | last post by:
Hello, I have a user control which I am trying to load dynamically, but am running into problems. I think the problem is because I have two .ascx files that refer to the same .ascx.cs file. A simple example is like this... Ferret1.ascx =========
7
3529
by: Jason | last post by:
I am trying to dynamically add a web user control - ctrlBlogEntry.ascx - to a page - default.aspx - (via an ASP:PlaceHolder). This web user control has two ASP:Label controls and I'm accessing their "Text" properties via public properties. However, after I have instantiated the ctrlBlogEntry control in the PageLoad method of default.aspx, it is failing when I try to set the text of the label controls in the ctrlBlogEntry control. Here...
0
950
by: Chris Davoli | last post by:
VS2005 - How do I reference a User Control from the ASPX page that I have placed the user control on? Here is the code I used from VS2003 and it worked, but for VS2005 it gives me a null reference ie; referenceUserControl.buttonRegister("Save") - this is a public method on the user control. How can I reference a user control from the page its placed on? Example: <%@ Page Language="VB" MasterPageFile="~/MasterPage.master"...
1
1532
by: malathyb | last post by:
Hi, I want to create a simple user control for the header and footer of my .aspx page. I've created the controls - it has simple html and no other server controls. When I try to include it on the page, by dragging it, the @register directive and the user control tag appear without any problem, but immediately, there is an error on the errors window, " 'index' is ambiguous". 'index' is my inherited class name.(partial class of the code behind...
2
3126
by: Kbalz | last post by:
I have a user control that has a gridview in it. I am dynamically setting up its datasource and columns based on an XML file. I have everything done except adding columns to the gridview, so that the user only sees certain columns based on the XML file. In my ASCX page I simply defined the gridview <asp:GridView ID="gvSearchResults" HorizontalAlign="Center" AllowSorting="true" runat="server"
6
10130
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void Page_Load(object sender, EventArgs e) { UserControls_WebUserControl myControl = new UserControls_WebUserControl(); PlaceHolder1.Controls.Add(web);
0
10789
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10504
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7755
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.