radiobuttonlist and javascript

Discussion in 'ASP .Net' started by sramruttun, Jul 21, 2003.

  1. sramruttun

    sramruttun Guest

    hi
    I have a checkbox and a radiobuttonlist (the radiobuttonlist contains 2
    items) in my form. The radiobuttonlist has its visible property set to false
    at design time. At run time, when the checkbox is checked, then I want the
    radiobuttonlist to appear. I want to use javascript.

    On Form_Load I've done:
    chkM.Attributes.Add("onclick", "ShowPeriod('" & RDLPeriod.ClientId &
    "');return false;")


    The HTML Source:

    <TR>
    <TD>
    <asp:Label id="Label8" runat="server">Monthly</asp:Label>&nbsp;
    <asp:CheckBox id="chkM" runat="server" Width="81px"></asp:CheckBox>
    </TD>
    <TD colSpan="3">
    <asp:Label id="Label9" runat="server">Period</asp:Label>&nbsp;
    <asp:RadioButtonList id="RDLPeriod" runat="server"
    RepeatDirection="Horizontal" Visible="False">
    <asp:ListItem Value="All">All</asp:ListItem>
    <asp:ListItem Value="Current Year">Current Year</asp:ListItem>
    </asp:RadioButtonList>
    </TD>
    </TR>


    In the script section I have:
    function ShowPeriod(w)
    {
    document.all(w).visible=true;
    //document.getElementById("RDLPeriod").style.visibility=true;
    }

    Upon execution, when I check the checkbox, the code breaks in the script
    section and tells that :
    'document.all(...)' is null or not an object

    Where is problem guys ?
     
    sramruttun, Jul 21, 2003
    #1
    1. Advertising

  2. sramruttun

    sramruttun Guest

    thanks marina
    I realise the point. What do u suggest?

    "Marina" <> wrote in message
    news:#...
    > Setting the visible property of a server side object to False, means that
    > the HTML for it doesn't even get streamed down to the client. This is very
    > different from setting the "display:none" in the style of the object.
    >
    > The problem is, the HTML for your radiobuttonlist never made it to the
    > client. This will be easy to check by chosing View -> Source from the menu
    > in IE.
    >
    > "sramruttun" <> wrote in message
    > news:%...
    > > hi
    > > I have a checkbox and a radiobuttonlist (the radiobuttonlist contains 2
    > > items) in my form. The radiobuttonlist has its visible property set to

    > false
    > > at design time. At run time, when the checkbox is checked, then I want

    the
    > > radiobuttonlist to appear. I want to use javascript.
    > >
    > > On Form_Load I've done:
    > > chkM.Attributes.Add("onclick", "ShowPeriod('" & RDLPeriod.ClientId &
    > > "');return false;")
    > >
    > >
    > > The HTML Source:
    > >
    > > <TR>
    > > <TD>
    > > <asp:Label id="Label8" runat="server">Monthly</asp:Label>&nbsp;
    > > <asp:CheckBox id="chkM" runat="server" Width="81px"></asp:CheckBox>
    > > </TD>
    > > <TD colSpan="3">
    > > <asp:Label id="Label9" runat="server">Period</asp:Label>&nbsp;
    > > <asp:RadioButtonList id="RDLPeriod" runat="server"
    > > RepeatDirection="Horizontal" Visible="False">
    > > <asp:ListItem Value="All">All</asp:ListItem>
    > > <asp:ListItem Value="Current Year">Current Year</asp:ListItem>
    > > </asp:RadioButtonList>
    > > </TD>
    > > </TR>
    > >
    > >
    > > In the script section I have:
    > > function ShowPeriod(w)
    > > {
    > > document.all(w).visible=true;
    > > //document.getElementById("RDLPeriod").style.visibility=true;
    > > }
    > >
    > > Upon execution, when I check the checkbox, the code breaks in the script
    > > section and tells that :
    > > 'document.all(...)' is null or not an object
    > >
    > > Where is problem guys ?
    > >
    > >

    >
    >
     
    sramruttun, Jul 22, 2003
    #2
    1. Advertising

  3. Sam,

    Attach the javascript at the same time you set the list to visible, and
    remove it if the list's visiblity is reset to false.

    chkM.Attributes.Remove("onclick")

    I hope this helps.

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "sramruttun" <> wrote in message
    news:...
    > thanks marina
    > I realise the point. What do u suggest?
    >
    > "Marina" <> wrote in message
    > news:#...
    > > Setting the visible property of a server side object to False, means

    that
    > > the HTML for it doesn't even get streamed down to the client. This is

    very
    > > different from setting the "display:none" in the style of the object.
    > >
    > > The problem is, the HTML for your radiobuttonlist never made it to the
    > > client. This will be easy to check by chosing View -> Source from the

    menu
    > > in IE.
    > >
    > > "sramruttun" <> wrote in message
    > > news:%...
    > > > hi
    > > > I have a checkbox and a radiobuttonlist (the radiobuttonlist contains

    2
    > > > items) in my form. The radiobuttonlist has its visible property set to

    > > false
    > > > at design time. At run time, when the checkbox is checked, then I want

    > the
    > > > radiobuttonlist to appear. I want to use javascript.
    > > >
    > > > On Form_Load I've done:
    > > > chkM.Attributes.Add("onclick", "ShowPeriod('" & RDLPeriod.ClientId &
    > > > "');return false;")
    > > >
    > > >
    > > > The HTML Source:
    > > >
    > > > <TR>
    > > > <TD>
    > > > <asp:Label id="Label8" runat="server">Monthly</asp:Label>&nbsp;
    > > > <asp:CheckBox id="chkM" runat="server" Width="81px"></asp:CheckBox>
    > > > </TD>
    > > > <TD colSpan="3">
    > > > <asp:Label id="Label9" runat="server">Period</asp:Label>&nbsp;
    > > > <asp:RadioButtonList id="RDLPeriod" runat="server"
    > > > RepeatDirection="Horizontal" Visible="False">
    > > > <asp:ListItem Value="All">All</asp:ListItem>
    > > > <asp:ListItem Value="Current Year">Current Year</asp:ListItem>
    > > > </asp:RadioButtonList>
    > > > </TD>
    > > > </TR>
    > > >
    > > >
    > > > In the script section I have:
    > > > function ShowPeriod(w)
    > > > {
    > > > document.all(w).visible=true;
    > > > //document.getElementById("RDLPeriod").style.visibility=true;
    > > > }
    > > >
    > > > Upon execution, when I check the checkbox, the code breaks in the

    script
    > > > section and tells that :
    > > > 'document.all(...)' is null or not an object
    > > >
    > > > Where is problem guys ?
    > > >
    > > >

    > >
    > >

    >
    >
     
    S. Justin Gengo, Jul 22, 2003
    #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. Leif
    Replies:
    1
    Views:
    427
    Helixpoint
    Jul 11, 2003
  2. Sean
    Replies:
    2
    Views:
    1,822
    Stuart Dickerson
    Aug 29, 2003
  3. Ryan Taylor
    Replies:
    2
    Views:
    14,623
    maclade
    Mar 20, 2008
  4. Alphonse Giambrone

    Set Radiobuttonlist Value via Javascript

    Alphonse Giambrone, Mar 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    14,504
    Alphonse Giambrone
    Mar 24, 2005
  5. Replies:
    5
    Views:
    38,060
Loading...

Share This Page