basic form question - two forms one page. ??

A

Aussie Rules

Hi,

I have an asp.net 2.0 page that has two sections. Each section allows the
user to enter a value into a text box, click a button and then perform some
function. Each text boxes function is different to the other and takes the
user to a different part of the web site after doing some SQL work

I have placed a form tag around each of the text boxes section. Each has a
different 'form id', however when i try to execute the web site, it says 'A
page can have only one server-side form tag.

How do i cope with my situation ?

Thanks
 
M

Mark Rae [MVP]

How do i cope with my situation ?

Use one form.

Each button has its own server-side events, so just take appropriate action
as required.

E.g.

Button1 does its processing and then does a Response.Redirect to page2.aspx
(or whatever)

Button2 does its processing and then does a Response.Redirect to page7.aspx
(or whatever)
 
T

Teemu Keiski

You can have multiple forms but only one can be server-side e.g with
runat="server". You can use cross-page postbacks in ASP.NET 2.0 to post on
different pages per button basis (set PostBackUrl="targetpage.aspx" on the
Button) while having single form on the Page. Assuming that you initiate
some task based on Button click...
 
S

Steven Cheng[MSFT]

Hi Aussie,

The ASP.NET web page is a customized html based web page, one particularity
is that ASP.NET web page use a <form> with "runat=server" attribute, this
is used as the container of any other ASP.NET server controls, and all
those server controls' postback event can be correctly detected if they're
put inside this server-side form tag. Also, there can only contains single
"runat=server" <form> tag in an ASP.NET web page.

For your scenario, if you want to post different data field entries through
different button on the same page, I think you can consider the following
two means:

1. If you're using ASP.NET 2.0, you can utilize the "cross-page post"
feature, this can let you define multiple buttons on a single page and
configure them to postbac k to different url:

#How to: Post ASP.NET Web Pages to a Different Page
http://msdn2.microsoft.com/en-us/library/ms178140.aspx

#Cross-Page Posting in ASP.NET Web Pages
http://msdn2.microsoft.com/en-us/library/ms178139.aspx


2. You can certainly put multiple html <form> tags in a single ASP.NET web
page. However, make sure that only one form has the "runat" attribute set
as "true". Also, for ASP.NET server controls, they can only be put in
"runat=server" <form> e.g.


=======in aspx page========

<body>
...
<form id="form1" runat="server">
you can put ASP.NET server controls here
.........
</form>

<form id="form2" action="other page'>
you can put only pure html elements here
........
</form>

<form id="form2" action="other page'>
you can put only pure html elements here
........
</form>
........
=============

If you have any more specific questions on this, please feel free to post
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hi Aussie,

Have you got any further idea on this issue or does the suggestion in
previous replies help you some? If there is anything else we can help,
please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Glad to be of assistance!

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top