get ID attribute from HTML buttons?

Discussion in 'ASP .Net' started by RN, Feb 20, 2005.

  1. RN

    RN Guest

    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?
     
    RN, Feb 20, 2005
    #1
    1. Advertising

  2. 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?
    >
    >
    >
     
    =?Utf-8?B?a2FzaHlwYQ==?=, Feb 21, 2005
    #2
    1. Advertising

  3. RN

    RN Guest

    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" <> wrote in message
    news:...
    > 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?
    > >
    > >
    > >
     
    RN, Feb 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger
    Replies:
    1
    Views:
    661
    GreggTB
    May 20, 2005
  2. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    475
    Teemu Keiski
    Jul 6, 2005
  3. Jeremy Jones

    Datagrid Nav buttons and numeric buttons

    Jeremy Jones, Mar 21, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    641
    Masudur
    Mar 22, 2007
  4. Jonathan N. Little
    Replies:
    3
    Views:
    545
    Andy Dingley
    Apr 2, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    328
    David Mark
    Oct 15, 2007
Loading...

Share This Page