473,241 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Multiple "Submit" Buttons & Form Fields

In ASPX 2.0 with MasterPages and all that, my entire page only has one actual
<FORM>. But there are several different sections of the page that provide
what are functionally separate forms with separate Submit buttons.

In basic HTML, I can have multiple forms on a page and the browser knows
that if any of the fields for Form A have the focus, then pressing ENTER will
send a Click to the submit button for Form A. Same for Form B, etc.

Since there's only one form in ASPX, how do I do this? Do I have to manage
all this with JavaScript and if so, do I have to write it myself or do the
controls have any built-in features for doing this?

Alex
May 6 '06 #1
5 19963
The model in ASP.NET is to simply to create different button click handlers
for the various buttons.

-Brock
http://staff.develop.com/ballen

In ASPX 2.0 with MasterPages and all that, my entire page only has one
actual <FORM>. But there are several different sections of the page
that provide what are functionally separate forms with separate Submit
buttons.

In basic HTML, I can have multiple forms on a page and the browser
knows that if any of the fields for Form A have the focus, then
pressing ENTER will send a Click to the submit button for Form A. Same
for Form B, etc.

Since there's only one form in ASPX, how do I do this? Do I have to
manage all this with JavaScript and if so, do I have to write it
myself or do the controls have any built-in features for doing this?

Alex

May 6 '06 #2
Yes but this isn't quite what I'm talking about: I'm talking about which of
the buttons effectively receives the client-side click based on which related
text box had the focus at the time that the ENTER key was pressed. In the old
multiple-forms approach in HTML, the browser handled this automatically.

Alex
"Brock Allen" wrote:
The model in ASP.NET is to simply to create different button click handlers
for the various buttons.

-Brock
http://staff.develop.com/ballen

In ASPX 2.0 with MasterPages and all that, my entire page only has one
actual <FORM>. But there are several different sections of the page
that provide what are functionally separate forms with separate Submit
buttons.

In basic HTML, I can have multiple forms on a page and the browser
knows that if any of the fields for Form A have the focus, then
pressing ENTER will send a Click to the submit button for Form A. Same
for Form B, etc.

Since there's only one form in ASPX, how do I do this? Do I have to
manage all this with JavaScript and if so, do I have to write it
myself or do the controls have any built-in features for doing this?

Alex


May 6 '06 #3
Ah, I see what you're saying. In 2.0 there's the ability to set a default
button, but that's still not what you want. You'd have to see what control
has focus upon submit and pass that info along to the server. You can use
Page.ClientScript.RegisterHiddenField and Page.ClientScript.RegisterOnSubmitStatement
to accomplish this.

-Brock
http://staff.develop.com/ballen

Yes but this isn't quite what I'm talking about: I'm talking about
which of the buttons effectively receives the client-side click based
on which related text box had the focus at the time that the ENTER key
was pressed. In the old multiple-forms approach in HTML, the browser
handled this automatically.

Alex

"Brock Allen" wrote:
The model in ASP.NET is to simply to create different button click
handlers for the various buttons.

-Brock
http://staff.develop.com/ballen
In ASPX 2.0 with MasterPages and all that, my entire page only has
one actual <FORM>. But there are several different sections of the
page that provide what are functionally separate forms with separate
Submit buttons.

In basic HTML, I can have multiple forms on a page and the browser
knows that if any of the fields for Form A have the focus, then
pressing ENTER will send a Click to the submit button for Form A.
Same for Form B, etc.

Since there's only one form in ASPX, how do I do this? Do I have to
manage all this with JavaScript and if so, do I have to write it
myself or do the controls have any built-in features for doing this?

Alex

May 6 '06 #4
Thanks for Brock's input,

Hi Alex,

As for multiple <form> support on ASP.NET page, it is somewhat a limitation
due to the original design of ASP.NET page. ASP.NET page use a single
runat="server" form to centralize all the server controls, this is very
important for the ASP.NET server-side to control the postback events for
the server controls(rely on such single server <form> structure...).
However, if want to want to to add is normal html <form> (not
runat=server), that is still ok. For example:

====================
<body>
<form id="form1" runat="server">
<div>
<select id="lst" runat="server" onchange="handlechange();" >
<option title="item1" value="item1">item1</option>
<option title="item2" value="item2">item2</option>
<option title="item3" value="item3">item3</option>
</select>

<br />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
<form id="form2" action="http://www.asp.net">
<input name="txtf2" type="text" />
</form>
</body>
</html>
====================

Anyway, only one "runat=server" element is allowed in single ASP.NET page.
Also, normal <form> can not be nested with each other.

In addition, if the reason you use multiple html <form> in single ASP.NET
page is just to post data to different page or address, you can consider
using the ASP.NET 2.0's new "cross page posting" feature.

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

#Design Considerations for Cross Page Post Backs in ASP.NET 2.0
http://www.odetocode.com/Articles/421.aspx

For the "default button" behavior, I'm afraid so far ASP.NET page only
support set such default submit button (when press "enter" key) for the
runat="server" form. For other form, you may still use own client-side
script to do this. For example, we can add the onkeydown or onkeypress
client-side script event for the <form> or <input type="text" > field, and
check the key code, it's enter key, call the form element's submit method.
Here are some articles mentioned such script:

http://jennifermadden.com/javascript...yDetector.html

http://www.cs.tut.fi/~jkorpela/forms/enter.html

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

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

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 8 '06 #5
Hi Alex,

Does those suggestion helps a little? Please feel free to post here if
there is anything else we can help.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

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

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sandyde2 | last post by:
Hi all, I get the tough problem and expect to get help.. In a html page, I dynamically created many forms which named as NO+business_id. In each form there are two submit buttons to...
0
by: Z GIRL | last post by:
Hi, I posted previously about trapping on the PostBack function exactly what submit button was clicked. I understand there is __EventArgument and __EventTarget hidden fields for a PostBack...
2
by: J. B. Moreno | last post by:
Is it possible to detect inside an onsubmit event /which/ button was pushed? I searched google and saw lots of suggestions for alternatives, but nobody outright saying it was impossible. At this...
5
by: Lau Lei Cheong | last post by:
Hello, Let's say that I have multiple submit buttons on a form (imagebuttons actually, but documentations say that <input type=image> which a called image buttons should behave like submit...
1
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine...
2
by: rudranee | last post by:
hello, How do i declare multiple submit buttons on a form? and how do i come to know on the next page which button has been clicked? Can i do it in JSP page? Please tell me.
2
by: fliss | last post by:
Hello I have four submit buttons on my page - each carrying a value which refreshes the page selects from my db and displays the results in the drop down. The prob is i would like another...
12
nehashri
by: nehashri | last post by:
hi i am doing a ASP front end. here I have 3 submit (buttons) in my page and one text box. well what i want is- when ever the user writes a name in text box and clicks on one of the submit that...
7
by: aashishn86 | last post by:
hi ! how can i use multiple submit buttons in the same form i want to pass form values to different pages depending on which of the two submit button is clicked... thank's
3
by: printline | last post by:
Hello All I have a form with multiple submit buttons, where i would like to open in a new window when hitting one of the submit buttons. Can't seem to figure this out according to the code i'm...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.