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

Nested Forms in ASP.NET

P: n/a
Hi,
As you all know when an ASP.NET web form is created that will include
web controls and such, it contains a
FORM that that identifies the web form and its containing controls.

Well, I have a web form who has several other (user & custom) controls,
these are enclosed within the standard
FORM tag. Additionally *some* of these user controls are actually forms as
well. This results into nested Forms.

I was noticing that this seems to cause certain confusion on the browser
sometimes. I checked the HTML and it is ok.

It has the following forms:
1. ASP.NET Web Form tag (Form1)
2. Login form (Login)
3. Google search form (Google)
4. PayPal form (PayPal)

2 through 4 are obviously embedded into the #1 form. On FireFox I notice
that one of the forms is not reported by the PageInfo dialog (very handy
tool). I reported it as a bug there but I wonder if this actually causes
problems with ASP.NET. Why? because when the order of my forms were 1, 4, 2,
3 and I had a user control that had a form as well (that would have been
just the ASP.NET web controls without FORM tag because it is always
contained in #1) then the "Submit" button would no longer work.

Strange... Now in the order shows above (1.2.3.4) the submit button works
(you can click and it posts back). Any ideas?

Thx
Emilio
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
User controls should generally not contain Form tags, or else it causes
problems like you're describing.
Other details:
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one at
a time.
Or you can have more than one form visible on your page at a time, but only
one of them can be a server form (i.e. with the runat=server attribute.)
Server forms only support posting back to themselves (not to other pages.)
This will all become more flexible in .NET version 2.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
Hi,
As you all know when an ASP.NET web form is created that will include
web controls and such, it contains a
FORM that that identifies the web form and its containing controls.

Well, I have a web form who has several other (user & custom) controls,
these are enclosed within the standard
FORM tag. Additionally *some* of these user controls are actually forms as
well. This results into nested Forms.

I was noticing that this seems to cause certain confusion on the browser
sometimes. I checked the HTML and it is ok.

It has the following forms:
1. ASP.NET Web Form tag (Form1)
2. Login form (Login)
3. Google search form (Google)
4. PayPal form (PayPal)

2 through 4 are obviously embedded into the #1 form. On FireFox I notice
that one of the forms is not reported by the PageInfo dialog (very handy
tool). I reported it as a bug there but I wonder if this actually causes
problems with ASP.NET. Why? because when the order of my forms were 1, 4,
2, 3 and I had a user control that had a form as well (that would have
been just the ASP.NET web controls without FORM tag because it is always
contained in #1) then the "Submit" button would no longer work.

Strange... Now in the order shows above (1.2.3.4) the submit button works
(you can click and it posts back). Any ideas?

Thx
Emilio

Nov 19 '05 #2

P: n/a
Yes, actually I forgot to mention that only Form #1 was a server form
(runat), all the others are "regular" forms but are nested within the server
form. Would that cause problems as well?

The issue is that the "master" page contains the server form, within the
form there is an HTML table that splits the web form into 3 columns (left &
right navigation panel and mid content panel). There can be "applets" on the
left and right sides, these are simple regular forms (normal HTML forms),
but the whole thing is within the server form, only they don't have a runat
attribute.

Regards,
Emilio

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
User controls should generally not contain Form tags, or else it causes
problems like you're describing.
Other details:
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one
at a time.
Or you can have more than one form visible on your page at a time, but
only one of them can be a server form (i.e. with the runat=server
attribute.)
Server forms only support posting back to themselves (not to other pages.)
This will all become more flexible in .NET version 2.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
Hi,
As you all know when an ASP.NET web form is created that will include
web controls and such, it contains a
FORM that that identifies the web form and its containing controls.

Well, I have a web form who has several other (user & custom) controls,
these are enclosed within the standard
FORM tag. Additionally *some* of these user controls are actually forms
as well. This results into nested Forms.

I was noticing that this seems to cause certain confusion on the browser
sometimes. I checked the HTML and it is ok.

It has the following forms:
1. ASP.NET Web Form tag (Form1)
2. Login form (Login)
3. Google search form (Google)
4. PayPal form (PayPal)

2 through 4 are obviously embedded into the #1 form. On FireFox I notice
that one of the forms is not reported by the PageInfo dialog (very handy
tool). I reported it as a bug there but I wonder if this actually causes
problems with ASP.NET. Why? because when the order of my forms were 1, 4,
2, 3 and I had a user control that had a form as well (that would have
been just the ASP.NET web controls without FORM tag because it is always
contained in #1) then the "Submit" button would no longer work.

Strange... Now in the order shows above (1.2.3.4) the submit button works
(you can click and it posts back). Any ideas?

Thx
Emilio


Nov 19 '05 #3

P: n/a
I don't believe the HTML specification supports nested forms.
Multiple forms are ok, but not inside eachother.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:OE**************@TK2MSFTNGP15.phx.gbl...
Yes, actually I forgot to mention that only Form #1 was a server form
(runat), all the others are "regular" forms but are nested within the
server form. Would that cause problems as well?

The issue is that the "master" page contains the server form, within the
form there is an HTML table that splits the web form into 3 columns (left
& right navigation panel and mid content panel). There can be "applets" on
the left and right sides, these are simple regular forms (normal HTML
forms), but the whole thing is within the server form, only they don't
have a runat attribute.

Regards,
Emilio

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
User controls should generally not contain Form tags, or else it causes
problems like you're describing.
Other details:
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one
at a time.
Or you can have more than one form visible on your page at a time, but
only one of them can be a server form (i.e. with the runat=server
attribute.)
Server forms only support posting back to themselves (not to other
pages.)
This will all become more flexible in .NET version 2.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
Hi,
As you all know when an ASP.NET web form is created that will include
web controls and such, it contains a
FORM that that identifies the web form and its containing controls.

Well, I have a web form who has several other (user & custom) controls,
these are enclosed within the standard
FORM tag. Additionally *some* of these user controls are actually forms
as well. This results into nested Forms.

I was noticing that this seems to cause certain confusion on the browser
sometimes. I checked the HTML and it is ok.

It has the following forms:
1. ASP.NET Web Form tag (Form1)
2. Login form (Login)
3. Google search form (Google)
4. PayPal form (PayPal)

2 through 4 are obviously embedded into the #1 form. On FireFox I notice
that one of the forms is not reported by the PageInfo dialog (very handy
tool). I reported it as a bug there but I wonder if this actually causes
problems with ASP.NET. Why? because when the order of my forms were 1,
4, 2, 3 and I had a user control that had a form as well (that would
have been just the ASP.NET web controls without FORM tag because it is
always contained in #1) then the "Submit" button would no longer work.

Strange... Now in the order shows above (1.2.3.4) the submit button
works (you can click and it posts back). Any ideas?

Thx
Emilio



Nov 19 '05 #4

P: n/a
Then what would be the best way to handle it? it all has to do with how the
page functions:

+-------------------------------------------------------------------------------------+
| [HEADER]
|
+------------------+---------------------------------------------+--------------------+
| LEFT PANE | MIDDLE PANE
| RIGHT PANE |
| [Literal] |
| |
| [Form A] | Content
| [Literal] |
| | [Possibly some web controls]
| [Form B] |
| |
| [Form C] |
+------------------+---------------------------------------------+-------------------+
| F O O T E R
|
+--------------------------------------------------------------------------------------+

Form A: Login HTML form (not an ASP.NET form)
Form B: Google search form (not an ASP.NET form)
Form C: PayPal button form (not an ASP.NET form) <- UserControl

And then, HEADER is an ASP.NET composite control, and the two Literals, as
well as some
that *may* appear in the middle pane are the simple ASP.NET WebControls
(TextBox, Literal,
Button, radioButton, etc.). Because of that those need to be enclosed in the
ASP.NET server
form (form id="Form1").

I don't think ASP.NET is not able to handle this sort of layout which is not
complex at all and
since I cannot have multiple server forms I cannot regroup the literals and
the other web controls
to beginning or end without totally destroying the page layout.

As you can see, this is some sort of page template. Anyway suggestions are
appreciated.

Regards,
Emilio
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ei**************@tk2msftngp13.phx.gbl...
I don't believe the HTML specification supports nested forms.
Multiple forms are ok, but not inside eachother.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:OE**************@TK2MSFTNGP15.phx.gbl...
Yes, actually I forgot to mention that only Form #1 was a server form
(runat), all the others are "regular" forms but are nested within the
server form. Would that cause problems as well?

The issue is that the "master" page contains the server form, within the
form there is an HTML table that splits the web form into 3 columns (left
& right navigation panel and mid content panel). There can be "applets"
on the left and right sides, these are simple regular forms (normal HTML
forms), but the whole thing is within the server form, only they don't
have a runat attribute.

Regards,
Emilio

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
User controls should generally not contain Form tags, or else it causes
problems like you're describing.
Other details:
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one
at a time.
Or you can have more than one form visible on your page at a time, but
only one of them can be a server form (i.e. with the runat=server
attribute.)
Server forms only support posting back to themselves (not to other
pages.)
This will all become more flexible in .NET version 2.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
Hi,
As you all know when an ASP.NET web form is created that will
include web controls and such, it contains a
FORM that that identifies the web form and its containing controls.

Well, I have a web form who has several other (user & custom) controls,
these are enclosed within the standard
FORM tag. Additionally *some* of these user controls are actually forms
as well. This results into nested Forms.

I was noticing that this seems to cause certain confusion on the
browser sometimes. I checked the HTML and it is ok.

It has the following forms:
1. ASP.NET Web Form tag (Form1)
2. Login form (Login)
3. Google search form (Google)
4. PayPal form (PayPal)

2 through 4 are obviously embedded into the #1 form. On FireFox I
notice that one of the forms is not reported by the PageInfo dialog
(very handy tool). I reported it as a bug there but I wonder if this
actually causes problems with ASP.NET. Why? because when the order of
my forms were 1, 4, 2, 3 and I had a user control that had a form as
well (that would have been just the ASP.NET web controls without FORM
tag because it is always contained in #1) then the "Submit" button
would no longer work.

Strange... Now in the order shows above (1.2.3.4) the submit button
works (you can click and it posts back). Any ideas?

Thx
Emilio



Nov 19 '05 #5

P: n/a
Try making the middle pane a form run at the server, and put everything else
(including other forms) outside that form. You can still run other items
outside the form at the server, so you could dynamically change the header.

HTH, ME

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:e6**************@TK2MSFTNGP11.phx.gbl...
Then what would be the best way to handle it? it all has to do with how the page functions:

+---------------------------------------------------------------------------
----------+ | [HEADER]
|
+------------------+---------------------------------------------+----------
----------+ | LEFT PANE | MIDDLE PANE
| RIGHT PANE |
| [Literal] |
| |
| [Form A] | Content
| [Literal] |
| | [Possibly some web controls]
| [Form B] |
| |
| [Form C] |
+------------------+---------------------------------------------+----------
---------+ | F O O T E R
|
+---------------------------------------------------------------------------
-----------+
Form A: Login HTML form (not an ASP.NET form)
Form B: Google search form (not an ASP.NET form)
Form C: PayPal button form (not an ASP.NET form) <- UserControl

And then, HEADER is an ASP.NET composite control, and the two Literals, as
well as some
that *may* appear in the middle pane are the simple ASP.NET WebControls
(TextBox, Literal,
Button, radioButton, etc.). Because of that those need to be enclosed in the ASP.NET server
form (form id="Form1").

I don't think ASP.NET is not able to handle this sort of layout which is not complex at all and
since I cannot have multiple server forms I cannot regroup the literals and the other web controls
to beginning or end without totally destroying the page layout.

As you can see, this is some sort of page template. Anyway suggestions are
appreciated.

Regards,
Emilio
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ei**************@tk2msftngp13.phx.gbl...
I don't believe the HTML specification supports nested forms.
Multiple forms are ok, but not inside eachother.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:OE**************@TK2MSFTNGP15.phx.gbl...
Yes, actually I forgot to mention that only Form #1 was a server form
(runat), all the others are "regular" forms but are nested within the
server form. Would that cause problems as well?

The issue is that the "master" page contains the server form, within the form there is an HTML table that splits the web form into 3 columns (left & right navigation panel and mid content panel). There can be "applets"
on the left and right sides, these are simple regular forms (normal HTML forms), but the whole thing is within the server form, only they don't
have a runat attribute.

Regards,
Emilio

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
User controls should generally not contain Form tags, or else it causes problems like you're describing.
Other details:
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one at a time.
Or you can have more than one form visible on your page at a time, but
only one of them can be a server form (i.e. with the runat=server
attribute.)
Server forms only support posting back to themselves (not to other
pages.)
This will all become more flexible in .NET version 2.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"~~~ .NET Ed ~~~" <ti*********@abolishspam.now> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
> Hi,
> As you all know when an ASP.NET web form is created that will
> include web controls and such, it contains a
> FORM that that identifies the web form and its containing controls.
>
> Well, I have a web form who has several other (user & custom) controls,> these are enclosed within the standard
> FORM tag. Additionally *some* of these user controls are actually forms> as well. This results into nested Forms.
>
> I was noticing that this seems to cause certain confusion on the
> browser sometimes. I checked the HTML and it is ok.
>
> It has the following forms:
> 1. ASP.NET Web Form tag (Form1)
> 2. Login form (Login)
> 3. Google search form (Google)
> 4. PayPal form (PayPal)
>
> 2 through 4 are obviously embedded into the #1 form. On FireFox I
> notice that one of the forms is not reported by the PageInfo dialog
> (very handy tool). I reported it as a bug there but I wonder if this
> actually causes problems with ASP.NET. Why? because when the order of
> my forms were 1, 4, 2, 3 and I had a user control that had a form as
> well (that would have been just the ASP.NET web controls without FORM
> tag because it is always contained in #1) then the "Submit" button
> would no longer work.
>
> Strange... Now in the order shows above (1.2.3.4) the submit button
> works (you can click and it posts back). Any ideas?
>
> Thx
> Emilio
>



Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.