Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > get ID attribute from HTML buttons?

Reply
Thread Tools

get ID attribute from HTML buttons?

 
 
RN
Guest
Posts: n/a
 
      02-20-2005
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?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?a2FzaHlwYQ==?=
Guest
Posts: n/a
 
      02-21-2005
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?
>
>
>

 
Reply With Quote
 
 
 
 
RN
Guest
Posts: n/a
 
      02-21-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation (XHTML 1.0 Transitional): Attribute 'leftmargin' is not a valid attribute of element 'body'. anonymous ASP .Net 1 08-02-2006 08:05 AM
picking value of one attribute based on a child elements attribute? XPath? vjethava@gmail.com XML 2 03-06-2006 05:19 AM
Implied instance attribute creation when referencing a class attribute Russell Warren Python 5 01-17-2006 05:07 AM
XSLT: Making attribute to parent attribute Bostonasian XML 1 09-18-2005 07:30 AM
class attribute to instance attribute Donnal Walter Python 4 07-06-2005 04:35 AM



Advertisments