Re: Multiple Form tags on a single page

  • Thread starter Steve C. Orr [MVP, MCSD]
  • Start date
S

Steve C. Orr [MVP, MCSD]

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.)

It's my understanding that 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


tmeister said:
I understand that a single aspx page can only contain on server form tag.
What are the other options. I have a user control on part of the majority
of my pages and want to include a search text box. Unfortunately several of
the pages that this user control appears on also contains a server form tag.
 
J

Jeffrey Palermo [MCP]

Tmeister,
Yes. I think a lot of people forget about how HTML works when they dig
into ASP.NET. You can have a million regular <form method="post"
action="somepage.aspx"> tags, and you can have regular form elements with a
regular submit button that posts information to an ASP or ASPX of your
choosing. Then on the called page, just get Request.Form["myVar"] on
Page_Load, and it works great. You just cannot have more than one form with
runat="server" because then ASP.NET's post-back stuff won't work. If
traditional form posting will suit your purposes, use it! It's simpler, and
it consumes fewer server resources.

Best regards,
Jeffrey Palermo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top