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

basic form question - two forms one page. ??

P: n/a
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

Aug 11 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
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)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 11 '07 #2

P: n/a
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...

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
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

Aug 12 '07 #3

P: n/a
Hi Aussie,

The ASP.NET web page is a customized html based web page, one particularity
is that ASP.NET web page use a <formwith "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" <formtag 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 <formtags 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/subscripti...ult.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/subscripti...t/default.aspx.

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


Aug 13 '07 #4

P: n/a
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.

Aug 15 '07 #5

P: n/a
Hi,

thanks this is now sorted with you input..

thanks
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:FP**************@TK2MSFTNGHUB02.phx.gbl...
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.
Aug 15 '07 #6

P: n/a
Glad to be of assistance!

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Aug 15 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.