RadioButton Control

Discussion in 'ASP .Net' started by =?Utf-8?B?QWNl?=, Jul 25, 2007.

  1. Hello,
    How can I make RadioButtons to display all in the same row? It looks that
    one Radio button per line by default.
    Secondly, I was wondering if there is a way to fire up Javascript when a
    Radio Button is selected. For example, depending on which Radio button gets
    selected, I need to show/hide a text box. Is it something I need to use
    Asp.Net AJAX (or easier way)?

    Thanks....a
     
    =?Utf-8?B?QWNl?=, Jul 25, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?QWNl?=

    Masudur Guest

    On Jul 25, 11:50 pm, Ace <> wrote:
    > Hello,
    > How can I make RadioButtons to display all in the same row? It looks that
    > one Radio button per line by default.
    > Secondly, I was wondering if there is a way to fire up Javascript when a
    > Radio Button is selected. For example, depending on which Radio button gets
    > selected, I need to show/hide a text box. Is it something I need to use
    > Asp.Net AJAX (or easier way)?
    >
    > Thanks....a


    hi...

    why dont you use Radio Button List... and change the "RepeatDirection"
    to "Horizontal"...
    but if you dont want to use radioButtonList... use css to control the
    flow of the radiobuttons...
    drop them in single div.. and set style to display:inline;.....

    about the javascript part... if you are on radio buttonlist... loop
    through them items and then add onclick attribute and then set a
    javascript

    foreach (ListItem item in RadioButtonList1.Items)
    {
    item.Attributes.Add("onClick",
    "window.alert('yahoo');");
    }
    some thing like that...
    in javascript fuction hide show the textbox... depending on the radio
    checked or not...

    Thanks
    Md. Masudur Rahman (Munna)
    Kaz Software Ltd.
    www.kaz.com.bd
    http://munnacs.110mb.com
     
    Masudur, Jul 26, 2007
    #2
    1. Advertising

  3. Thanx Masudur,
    I have not added an event to a control and I assume I do this as part of
    page load or init?

    "Masudur" wrote:

    > On Jul 25, 11:50 pm, Ace <> wrote:
    > > Hello,
    > > How can I make RadioButtons to display all in the same row? It looks that
    > > one Radio button per line by default.
    > > Secondly, I was wondering if there is a way to fire up Javascript when a
    > > Radio Button is selected. For example, depending on which Radio button gets
    > > selected, I need to show/hide a text box. Is it something I need to use
    > > Asp.Net AJAX (or easier way)?
    > >
    > > Thanks....a

    >
    > hi...
    >
    > why dont you use Radio Button List... and change the "RepeatDirection"
    > to "Horizontal"...
    > but if you dont want to use radioButtonList... use css to control the
    > flow of the radiobuttons...
    > drop them in single div.. and set style to display:inline;.....
    >
    > about the javascript part... if you are on radio buttonlist... loop
    > through them items and then add onclick attribute and then set a
    > javascript
    >
    > foreach (ListItem item in RadioButtonList1.Items)
    > {
    > item.Attributes.Add("onClick",
    > "window.alert('yahoo');");
    > }
    > some thing like that...
    > in javascript fuction hide show the textbox... depending on the radio
    > checked or not...
    >
    > Thanks
    > Md. Masudur Rahman (Munna)
    > Kaz Software Ltd.
    > www.kaz.com.bd
    > http://munnacs.110mb.com
    >
    >
     
    =?Utf-8?B?QWNl?=, Jul 26, 2007
    #3
  4. Hi Ace

    > Secondly, I was wondering if there is a way to fire up Javascript when a
    > Radio Button is selected. For example, depending on which Radio button
    > gets
    > selected, I need to show/hide a text box. Is it something I need to use
    > Asp.Net AJAX (or easier way)?

    The RadioButtonList provides a property named "AutoPostBack".
    If the property set to true, a postback through javascript fired.
    -
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.autopostback.aspx

    --
    Gruss, Peter Bucher
    Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
    http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
    http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
     
    Peter Bucher [MVP], Jul 26, 2007
    #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. Sundar
    Replies:
    0
    Views:
    397
    Sundar
    Dec 9, 2003
  2. John Holmes

    Using data to name a radioButton control

    John Holmes, Feb 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,742
    John Holmes
    Feb 4, 2004
  3. bredal Jensen
    Replies:
    0
    Views:
    507
    bredal Jensen
    Apr 26, 2004
  4. Replies:
    0
    Views:
    3,660
  5. Tom wilson
    Replies:
    7
    Views:
    4,128
    William F. Robertson, Jr.
    Feb 10, 2005
Loading...

Share This Page