473,734 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to differentiate between click event of multiple server buttons

Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike

Jun 5 '06 #1
5 2455
the wiring is pretty simple. a submit button, is a html form element. take
this simple html, with a text box and two submits.
<html>
<body>
<form name=f1 method=post action="foo1.as px">
<input type=hidden name=input1 value=hiddenval ue>
<input type=submit name=submit1 value=submit value=value1>
<input type=submit name=submit2 value=submit value=value2>
<button name=button1 value=value3
onclick="docume nt.forms[0].submit()">
</form>
</body>
</html>

if the use clicks on submit button, the browser does a form post including
the name/value pairs of the form elements (input, submit, select and
textarea). there are some rules on which elements are included.

if type=submit button will only be posted if clicked.
if type=checkbox will be included if checked == true
if type=radio will be included if checked == true
the element must be enabled to postbcak its value
if type=image, must be clicked and also sends name_x and name_y values.

if the user clicks submit1, the postback data is

input1=hiddenva lue@submit1=val ue1

if the user clicks submit2, the postback data is

input1=hiddenva lue@submit2=val ue2

if the user clicks button1, the postback data is

input1=hiddenva lue

as buttons (which are not a form elements) do not post back values, and a
script triggered postback will not include any type=submit values.

for auto postback controls (like the dropdown), client script fills in a
hidden field named "__EVENTTARGET" , where the postback control name is
written, then the client script calls "form.submit()" , which will not
include any submit buttons in the postback data.

note: you can also have more than one form, but only the element values of
one of the forms is postedback.
-- bruce (sqlwork.com)
<ma***********@ hotmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike

Jun 5 '06 #2
Lit
Bruce,

If my checkbox was checked to begin with and I uncheck it before I hit the
Submit button then the server knows that I unchecked the checkbox just
because its value was not posted back? What was the reason to have such
rules? more efficient?
Where did "<input type=hidden name=input1 value=hiddenval ue>" come from?
Auto generated?

what is value=submit value=value1 < causing error
do you have an example that works and well formed <html> or xhtml

Lit


"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com> wrote
in message news:ON******** ******@TK2MSFTN GP03.phx.gbl...
the wiring is pretty simple. a submit button, is a html form element. take
this simple html, with a text box and two submits.
<html>
<body>
<form name=f1 method=post action="foo1.as px">
<input type=hidden name=input1 value=hiddenval ue>
<input type=submit name=submit1 value=submit value=value1>
<input type=submit name=submit2 value=submit value=value2>
<button name=button1 value=value3
onclick="docume nt.forms[0].submit()">
</form>
</body>
</html>

if the use clicks on submit button, the browser does a form post including
the name/value pairs of the form elements (input, submit, select and
textarea). there are some rules on which elements are included.

if type=submit button will only be posted if clicked.
if type=checkbox will be included if checked == true
if type=radio will be included if checked == true
the element must be enabled to postbcak its value
if type=image, must be clicked and also sends name_x and name_y values.

if the user clicks submit1, the postback data is

input1=hiddenva lue@submit1=val ue1

if the user clicks submit2, the postback data is

input1=hiddenva lue@submit2=val ue2

if the user clicks button1, the postback data is

input1=hiddenva lue

as buttons (which are not a form elements) do not post back values, and a
script triggered postback will not include any type=submit values.

for auto postback controls (like the dropdown), client script fills in a
hidden field named "__EVENTTARGET" , where the postback control name is
written, then the client script calls "form.submit()" , which will not
include any submit buttons in the postback data.

note: you can also have more than one form, but only the element values of
one of the forms is postedback.
-- bruce (sqlwork.com)
<ma***********@ hotmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike


Jun 6 '06 #3
Hi Bruce,
Excellent...Mar velous...
I was looking for exactly such explanation. Thanks.
I am really oblidged for explaining me this stuff. I was really not
aware what is packed in an envelope when a button of type submit is
clicked.
Coupld you please post a link where I can read about this very BASIC
rules of how what elements of a form is posted. Because sometime I use
readonly textboxes and sometimes they are disables and I set is values
using javascript and when I postback I get values for some controls
while not for other controls depending on whether they are READONLY or
Disabled.
Thanks again for sharing this basic but very important to remember
technics.
--Mike

bruce barker (sqlwork.com) wrote:
the wiring is pretty simple. a submit button, is a html form element. take
this simple html, with a text box and two submits.
<html>
<body>
<form name=f1 method=post action="foo1.as px">
<input type=hidden name=input1 value=hiddenval ue>
<input type=submit name=submit1 value=submit value=value1>
<input type=submit name=submit2 value=submit value=value2>
<button name=button1 value=value3
onclick="docume nt.forms[0].submit()">
</form>
</body>
</html>

if the use clicks on submit button, the browser does a form post including
the name/value pairs of the form elements (input, submit, select and
textarea). there are some rules on which elements are included.

if type=submit button will only be posted if clicked.
if type=checkbox will be included if checked == true
if type=radio will be included if checked == true
the element must be enabled to postbcak its value
if type=image, must be clicked and also sends name_x and name_y values.

if the user clicks submit1, the postback data is

input1=hiddenva lue@submit1=val ue1

if the user clicks submit2, the postback data is

input1=hiddenva lue@submit2=val ue2

if the user clicks button1, the postback data is

input1=hiddenva lue

as buttons (which are not a form elements) do not post back values, and a
script triggered postback will not include any type=submit values.

for auto postback controls (like the dropdown), client script fills in a
hidden field named "__EVENTTARGET" , where the postback control name is
written, then the client script calls "form.submit()" , which will not
include any submit buttons in the postback data.

note: you can also have more than one form, but only the element values of
one of the forms is postedback.
-- bruce (sqlwork.com)
<ma***********@ hotmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike


Jun 6 '06 #4
Hi Lit,
As I understand, It it is server side CheckBox and its viewstate is
TRUE then server can easily differentiate between the true and false
value when user changes it.
When it constructs the page object while postback operation it will
create all server side controls within the page andd set its properties
using "__ViewStat e". After that it checks to see the posted values and
applies them.
Now if the checkbox was originally checked then its value will be there
in "__ViewStat e". If user clears it and performs a PostBack then server
will first create checkbox with its original value i.e. checked=TRUE.
Then it will query the posted values in the Request.Form() collection.
If it does not find a checkbox in collection (as stated in Bruce's
post, if a checkbox is cleared it is not postedback) then the framework
will clear the checkbox value i.e. Checked=FALSE.
I hope this answers your question.
--Mike

Lit wrote:
Bruce,

If my checkbox was checked to begin with and I uncheck it before I hit the
Submit button then the server knows that I unchecked the checkbox just
because its value was not posted back? What was the reason to have such
rules? more efficient?
Where did "<input type=hidden name=input1 value=hiddenval ue>" come from?
Auto generated?

what is value=submit value=value1 < causing error
do you have an example that works and well formed <html> or xhtml

Lit


"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com> wrote
in message news:ON******** ******@TK2MSFTN GP03.phx.gbl...
the wiring is pretty simple. a submit button, is a html form element. take
this simple html, with a text box and two submits.
<html>
<body>
<form name=f1 method=post action="foo1.as px">
<input type=hidden name=input1 value=hiddenval ue>
<input type=submit name=submit1 value=submit value=value1>
<input type=submit name=submit2 value=submit value=value2>
<button name=button1 value=value3
onclick="docume nt.forms[0].submit()">
</form>
</body>
</html>

if the use clicks on submit button, the browser does a form post including
the name/value pairs of the form elements (input, submit, select and
textarea). there are some rules on which elements are included.

if type=submit button will only be posted if clicked.
if type=checkbox will be included if checked == true
if type=radio will be included if checked == true
the element must be enabled to postbcak its value
if type=image, must be clicked and also sends name_x and name_y values.

if the user clicks submit1, the postback data is

input1=hiddenva lue@submit1=val ue1

if the user clicks submit2, the postback data is

input1=hiddenva lue@submit2=val ue2

if the user clicks button1, the postback data is

input1=hiddenva lue

as buttons (which are not a form elements) do not post back values, and a
script triggered postback will not include any type=submit values.

for auto postback controls (like the dropdown), client script fills in a
hidden field named "__EVENTTARGET" , where the postback control name is
written, then the client script calls "form.submit()" , which will not
include any submit buttons in the postback data.

note: you can also have more than one form, but only the element values of
one of the forms is postedback.
-- bruce (sqlwork.com)
<ma***********@ hotmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike



Jun 6 '06 #5
Hi Bruce,
Excellent...Mar velous...
I was looking for exactly such explanation. Thanks.
I am really oblidged for explaining me this stuff. I was really not
aware what is packed in an envelope when a button of type submit is
clicked.
Coupld you please post a link where I can read about this very BASIC
rules of how what elements of a form is posted. Because sometime I use
readonly textboxes and sometimes they are disables and I set is values
using javascript and when I postback I get values for some controls
while not for other controls depending on whether they are READONLY or
Disabled.
Thanks again for sharing this basic but very important to remember
technics.
--Mike
bruce barker (sqlwork.com) wrote:
the wiring is pretty simple. a submit button, is a html form element. take
this simple html, with a text box and two submits.
<html>
<body>
<form name=f1 method=post action="foo1.as px">
<input type=hidden name=input1 value=hiddenval ue>
<input type=submit name=submit1 value=submit value=value1>
<input type=submit name=submit2 value=submit value=value2>
<button name=button1 value=value3
onclick="docume nt.forms[0].submit()">
</form>
</body>
</html>

if the use clicks on submit button, the browser does a form post including
the name/value pairs of the form elements (input, submit, select and
textarea). there are some rules on which elements are included.

if type=submit button will only be posted if clicked.
if type=checkbox will be included if checked == true
if type=radio will be included if checked == true
the element must be enabled to postbcak its value
if type=image, must be clicked and also sends name_x and name_y values.

if the user clicks submit1, the postback data is

input1=hiddenva lue@submit1=val ue1

if the user clicks submit2, the postback data is

input1=hiddenva lue@submit2=val ue2

if the user clicks button1, the postback data is

input1=hiddenva lue

as buttons (which are not a form elements) do not post back values, and a
script triggered postback will not include any type=submit values.

for auto postback controls (like the dropdown), client script fills in a
hidden field named "__EVENTTARGET" , where the postback control name is
written, then the client script calls "form.submit()" , which will not
include any submit buttons in the postback data.

note: you can also have more than one form, but only the element values of
one of the forms is postedback.
-- bruce (sqlwork.com)
<ma***********@ hotmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has made
the postback request.???"
for e.g.
I have a webpage default.aspx.
I place TWO or more server buttons on it.
Create server-side event handlers for each of the buttons.

Now run the application. If I look at the source HTML generated, it
shows "INPUT" element of type "SUBMIT" for each of the buttons and
since it is "SUBMIT" button it does not have any onclick event
associated with it by default.

I am really puzzled on ...
HOW server determines which button has been clicked.

because each time I click different button it really fireas the
appropriate event handlers on the serverr which is correct. But just
want to understand the underlying wiring.
Any lights on this will be greatly appreciated.
Thanks
--Mike


Jun 6 '06 #6

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

Similar topics

3
11299
by: DEK | last post by:
Stepping through my code the click eventhandler code executes through a few times before it finally stops. Even though I only click the button once, is there a reason for this, I have a few if else and method calls in the eventhandler. -- Thanks DEK
4
4028
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code ontop of the webform1: Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code "
1
1070
by: Galina Grechka | last post by:
Hi, I have this strange problem. After I recompiled my ASP.NET project and then open project as a user from web browser, code behing some buttons doesn't execute at all. It works on my (development) machine. But it doesn't on others machines in our LAN. Previous version of project (which was compiled 2 weeks ago) works fine on any machine. We all use browser Microsoft Internet Explorer version 6.
2
3867
by: mark | last post by:
Is there a means of raising an event when ANY button on a windows application form is clicked wherein the actual button clicked can be determined in the generic click events code (eg by way of interogating the sender)? -- mark
41
4314
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
0
2955
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it such as when they do a delete. Everything is great. By and large it will be used in my repeater controls using the command event when the user clicks on it and so that event is working great. My issue is the Click event. When the control is...
6
10085
by: Terry | last post by:
Good morning! How do I determine which SELECT button was clicked in a GridView? The multiple SELECT buttons will be used for an application approval process. Thank you in advance for your support in this matter.
3
2458
by: Andreas Wöckl | last post by:
HI Group! I have to programmatically create a user input form with various Checkbox and RadioButton lists - Beside every List I have to place an image button that is able to reset the checkboxlists and radiobutton lists. if i declare a variable with private withEvents img as ImageButton
19
4561
Frinavale
by: Frinavale | last post by:
I'm in the middle of implementing a custom Ajax enabled Server Control. At this point I need help finding the answer to an Ajax Framework question...here it goes: I have a Server Control that extends from a Panel and implements the IScriptControl interface: Public Class MyCustomControl Inherits Panel Implements IScriptControl This Server Control consists of a collection of Labels, Panels, Buttons, Literals, other Ajax...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.