473,500 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get ID attribute from HTML buttons?

RN
I am dynamically adding a number of HTML buttons to a page...

<input type="submit" name="alwaysthesame" id="different1"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different2"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different3"
value="alwaysthesame">

I want them all to have the same name NAME attribute and the same VALUE
attribute, but different ID attributes. This way I can have a bunch of
buttons and easily check for which one was pressed. Like having a "radio
button group" but instead it will be a "command button group" with each
button in a different place. I don't want to dynamically add server-side
controls because it would be really hard to have different NAME fields
considering that the number of buttons I have to create is different
depending upon the data.

The problem with "html only" way of sending the data is that I can't figure
out to how read the "id" value back from the server on postback. Is there
a way?
Nov 19 '05 #1
2 1923
Hi

When you are creating HTML only buttons no need for you to have different ID
to use. You can have all the button have a single name and in the server side
just say, Request["htmlButtonName"] you will get the value of the button that
was clicked. So just have different value for each of the button and you will
come to know which one was clicked.

I would suggest have multiple server buttons and write only one function
which handles click of all the button. You can use the Commandevent Args to
see which button was clicked.

regards
Lohith
Blore,
India
"RN" wrote:
I am dynamically adding a number of HTML buttons to a page...

<input type="submit" name="alwaysthesame" id="different1"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different2"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different3"
value="alwaysthesame">

I want them all to have the same name NAME attribute and the same VALUE
attribute, but different ID attributes. This way I can have a bunch of
buttons and easily check for which one was pressed. Like having a "radio
button group" but instead it will be a "command button group" with each
button in a different place. I don't want to dynamically add server-side
controls because it would be really hard to have different NAME fields
considering that the number of buttons I have to create is different
depending upon the data.

The problem with "html only" way of sending the data is that I can't figure
out to how read the "id" value back from the server on postback. Is there
a way?

Nov 19 '05 #2
RN
Yes, but the value attribute stupidly is what appears on the face of the
button and I want to store an ID number. Thus I WANT to use the ID
attribute. Is there a way of retrieve that?
"kashypa" <ka*****@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
Hi

When you are creating HTML only buttons no need for you to have different ID to use. You can have all the button have a single name and in the server side just say, Request["htmlButtonName"] you will get the value of the button that was clicked. So just have different value for each of the button and you will come to know which one was clicked.

I would suggest have multiple server buttons and write only one function
which handles click of all the button. You can use the Commandevent Args to see which button was clicked.

regards
Lohith
Blore,
India
"RN" wrote:
I am dynamically adding a number of HTML buttons to a page...

<input type="submit" name="alwaysthesame" id="different1"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different2"
value="alwaysthesame">
<input type="submit" name="alwaysthesame" id="different3"
value="alwaysthesame">

I want them all to have the same name NAME attribute and the same VALUE
attribute, but different ID attributes. This way I can have a bunch of
buttons and easily check for which one was pressed. Like having a "radio button group" but instead it will be a "command button group" with each
button in a different place. I don't want to dynamically add server-side controls because it would be really hard to have different NAME fields
considering that the number of buttons I have to create is different
depending upon the data.

The problem with "html only" way of sending the data is that I can't figure out to how read the "id" value back from the server on postback. Is there a way?

Nov 19 '05 #3

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

Similar topics

2
1399
by: Matt | last post by:
I want to know if we need id attribute? Or just name attribute is fine? For example: Name: <input type="text" id="text" name="fname">
1
3263
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
8
16223
by: Neil Zanella | last post by:
Hello, I would like to know why the W3C decided not to make the following valid XHTML: <input checked type="radio" name="foo" value="bar" />FooBar forcing people to write the following to...
1
2608
by: Griff | last post by:
Hi! I'm using JavaScript on an HTML page for form validation. I have a form value (theForm.ProdType1) which represents a picklist from which users may make multiple selections; essentially,...
5
2858
by: Soledad Vel | last post by:
Hi All, i write this code: var sliderwidth=100; var sliderheight = 100; var div1 = document.createElement('div'); div1.setAttribute('id','d5'); div1.setAttribute('style',...
13
1815
by: Mounir | last post by:
Hi, Assume that right and left are multiple select elements. It's about the following line : right.options=left.options; It copies the content of left.options into right.options, but...
11
5810
by: Jasbird | last post by:
Has the name attribute deprecated? I ask this because ASP.NET 2 warns me against using it, says that it has been deprecated and doesn't use it (on the client) when creating a radio button list....
1
6353
by: pechar | last post by:
Hi all, I'm absolutely lost and have no idea why this is happening. I have a master page where the form resides. I set an onsubmit attribute to call a method which sets a variable to true ...
1
1421
by: =?Utf-8?B?U3VtaXQgUmF3YXQgSW5kaWE=?= | last post by:
What I have seen in Asp.net applications that if i put two Asp buttons on the web form(Aspx page) it generates multiple name attribute of input tag on the client side. for eg. <asp:Button...
0
7136
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,...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7182
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,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
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 ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
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...

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.