Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Nested Forms in ASP.NET

Reply
Thread Tools

Nested Forms in ASP.NET

 
 
~~~ .NET Ed ~~~
Guest
Posts: n/a
 
      12-13-2004
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


 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      12-13-2004
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 ~~~" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
~~~ .NET Ed ~~~
Guest
Posts: n/a
 
      12-14-2004
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]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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 ~~~" <(E-Mail Removed)> wrote in message
> news:O$(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      12-14-2004
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 ~~~" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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 ~~~" <(E-Mail Removed)> wrote in message
>> news:O$(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
~~~ .NET Ed ~~~
Guest
Posts: n/a
 
      12-14-2004
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 ~~~" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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]" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> 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 ~~~" <(E-Mail Removed)> wrote in message
>>> news:O$(E-Mail Removed)...
>>>> 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
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Martin Eyles
Guest
Posts: n/a
 
      12-14-2004
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
http://www.velocityreviews.com/forums/(E-Mail Removed)



"~~~ .NET Ed ~~~" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >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 ~~~" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> 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]" <(E-Mail Removed)> wrote in message
> >> news:%(E-Mail Removed)...
> >>> 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 ~~~" <(E-Mail Removed)> wrote in message
> >>> news:O$(E-Mail Removed)...
> >>>> 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
> >>>>
> >>>
> >>>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
br00t br00t is offline
Junior Member
Join Date: May 2007
Posts: 1
 
      05-21-2007
One quick workaround is to simply make a little redirector page. I wrote a little post on that topic which you can check out at...

http://www.zen-turkey.com/blog/defau...-an-ASP-NET-Pa

No it does not provide you with a way to use nested forms (there is no good one) Hope it helps.

Cheers,

br00t
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dealing with nested xml within nested xml within...... Ultrus Python 3 07-09-2007 09:00 PM
Is nested class automatically friend of class that it is nested in? request@no_spam.com C++ 5 09-25-2006 08:31 AM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Nested Vector Nester Classes are Nested in my Brain Chad E. Dollins C++ 3 11-08-2005 04:46 AM
Nested iterators (well, not nested exactly...) Russ Perry Jr Java 2 08-20-2004 06:51 PM



Advertisments