Changing RadioButton's NAme and ID properties using vb.net

Discussion in 'ASP .Net Web Controls' started by Savas Ates, Mar 24, 2006.

  1. Savas Ates

    Savas Ates Guest

    I want to change my radiobutton's name ,id and value properties
    programmatically.



    RadioButton1.Attributes.Add("value", "Pele")

    RadioButton1.Attributes.Add("name", "R1")

    RadioButton1.Attributes.Add("id", "SAVAS")



    It returns

    <span name="R1" id="SAVAS" style="Z-INDEX: 101; LEFT: 8px; POSITION:
    absolute; TOP: 8px"><input id="RadioButton1" type="radio"
    name="RadioButton1" value="Pele" /></span>



    My first Html code is like that

    <asp:RadioButton id="RadioButton1" style="Z-INDEX: 101; LEFT: 8px; POSITION:
    absolute; TOP: 8px"
    runat="server"></asp:RadioButton>
    Savas Ates, Mar 24, 2006
    #1
    1. Advertising

  2. Savas Ates

    Guest

    RadioButton1.ID = "SAVAS"
    In place of the value attribute, you can use the text attribute.
    RadioButton1.Text = "Pele"
    The name attribute is deprecated in the xhtml standard and it's role is
    replaced by ID.

    Regards.
    , Mar 24, 2006
    #2
    1. Advertising

  3. Savas Ates

    jeff Guest

    Is your radio button HTML or ASP.NET?? If asp.net then do the following

    in the page load event do this...
    RadioButton1.Id = "value"
    RadioButton1.Text = "mytext";

    on the webpage add this

    <asp:radiobutton1 runat="server" />

    get all the juicy radiobutton information at msdn

    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.
    radiobutton_members.aspx
    jeff, Mar 24, 2006
    #3
  4. Savas Ates

    Guest

    By the way the <span ...>...</span> html block is the client side code
    - it's what you see when you look at the source of the browser side
    code.

    The <asp:RadioButton ...></asp:RadioButton> code block is the server
    side page - what you see in Visual Studio source view.

    The ASP.NET framework would render the server tags at runtime to
    specific html tags that is suitable for the browser on the client
    making the http request (adaptive rendering).

    Regards.
    , Mar 25, 2006
    #4
    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. David Whitney
    Replies:
    1
    Views:
    587
    Natty Gur
    Jul 21, 2003
  2. John Holmes

    Using data to name a radioButton control

    John Holmes, Feb 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,732
    John Holmes
    Feb 4, 2004
  3. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    810
    Roedy Green
    Jan 2, 2006
  4. ding feng
    Replies:
    2
    Views:
    2,790
    ding feng
    Jun 25, 2003
  5. Sonal
    Replies:
    3
    Views:
    656
Loading...

Share This Page