radiobuttonlist and javascript

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default radiobuttonlist and javascript

    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.visibil ity=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 Guest

  2. Similar Questions and Discussions

    1. RadioButtonList
      Maybe you can help me with the following logic I am trying to accomplish. My RadioButtonList is in datagrid <EditItemTemplate> column If my...
    2. RadioButtonList In DataGrid
      Hi all! I have a page that gets a list of users from a database and puts them into a DataGrid. The DataGrid is editable. In Edit Mode of the...
    3. Radiobuttonlist and cssclass
      I am in the process of updating old asp projects into asp.net. We used to have radiobuttons which had an attached css class as follows: <label...
    4. RadioButtonList and JavaScript ... Help
      Hi .... I have a radiobutton list and a label in a webform. <asp:radiobuttonlist id="one" runat="server" CssClass="text" AutoPostBack="False"...
    5. radiobuttonlist and javascript??
      in your page load function add the following: RadioButtonListName.Attributes.Add("onclick", "return JavascriptFunctionName()"); radiobuttonlist...
  3. #2

    Default Re: radiobuttonlist and javascript

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

    "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    news:#AtSIv5TDHA.3144@tk2msftngp13.phx.gbl...
    > 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" <sramruttun@yahoo.com> wrote in message
    > news:%23pPjrN4TDHA.556@TK2MSFTNGP12.phx.gbl...
    > > 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.visibil ity=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 Guest

  4. #3

    Default Re: radiobuttonlist and javascript

    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:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "sramruttun" <sramruttun@yahoo.com> wrote in message
    news:uMU1D9AUDHA.2520@tk2msftngp13.phx.gbl...
    > thanks marina
    > I realise the point. What do u suggest?
    >
    > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > news:#AtSIv5TDHA.3144@tk2msftngp13.phx.gbl...
    > > 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" <sramruttun@yahoo.com> wrote in message
    > > news:%23pPjrN4TDHA.556@TK2MSFTNGP12.phx.gbl...
    > > > 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.visibil ity=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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139