Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
function radio() {
           var m; var n = 0;
           m = parseInt(document.getElementById('<%= hdfcount.ClientID %>').value);

           for (j = 0; j < m; j++) {
               var Section = "CphrEMS_dlquestions_dlsecqustns_" + j;
               var Sectione = document.getElementById(Section);

               for (k = 0; k < Sectione.rows.length; k++) {
                   var Question = Section + "_txtqustn_" + k;
                   var dlOption = document.getElementById(Section + "_dloptions_" + k);
                   var txtlist = dlOption.getElementsByTagName("label");
                   for (l = 0; l < txtlist.length; l++) {
                       var Option = Section + "_dloptions_" + k + "_chkanswer_" + l;
                       document.getElementById(Option).name = k.toString();
                   }
               }
           }
       }



this way im setting group name to my radio buttons in client side. but after postback all the radio buttons getting cleared please help




html

C#
<asp:DataList runat="server" RepeatLayout="Table" ID="dlsecqustns">
                                            <itemtemplate>
                                                <table width="100%">
                                                    <tr>
                                                        <td align="left" width="2%" valign="top" style="padding-removed 25px;">
                                                            <asp:Label runat="server" Text='<%#Eval("qusnum") %>' ID="lblqustn">
                                                        </td>
                                                        <td align="left" width="82%" style="padding-removed 25px;">
                                                            <asp:TextBox ID="txtqustn" runat="server" TextMode="MultiLine" Height="32px" CssClass="textbox"
                                                                Width="70%">
                                                            <ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2"  runat="server" TargetControlID="txtqustn"
                                                                WatermarkText="Question" WatermarkCssClass="watermarked" />
                                                            <asp:FileUpload runat="server" ID="imgqustn" />
                                                            <%--Style="display: none;"--%>
                                                            <br />
                                                            <asp:DataList runat="server" RepeatLayout="Table" ID="dloptions" RepeatDirection="Horizontal"
                                                                RepeatColumns="4">
                                                                <itemtemplate>
                                                                    <table width="99%">
                                                                        <tr>
                                                                            <td width="25%" style="padding: 15px 0 0 0;">
                                                                                <table width="100%">
                                                                                    <tr>
                                                                                        <td align="left">
                                                                                            <asp:Label runat="server" ID="lbloptnum" CssClass="label" Text='<%#Eval("optnum") %>'><span>.</span>
                                                                                            <asp:TextBox runat="server" TextMode="MultiLine" Width="70%" CssClass="textbox" ID="txtoptions"> 
                                                                                           <div  runat="server" id="divrbtn"  önclick="return radiobtn(this.id)">
                                                                                            <asp:RadioButton runat="server" Text="Answer" ID="chkanswer" />
                                                                                             
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td align="center" width="25%">
                                                                                            <br />
                                                                                            <input id="uploadFile" style="display: none;" class="textbx"  runat="server" placeholder="Choose File"
                                                                                                disabled="disabled" />
                                                                                            <div id="filediv"  runat="server" style="display: none;" class="fileUpload btn btn-primary">
                                                                                                <span>Upload</span><input id="file"  runat="server"  önchange="CopyMe(this, this.id)"
                                                                                                    type="file" class="upload" />
                                                                                            
                                                                                            <%--Style="display: none;"--%>
                                                                                            <%--<asp:FileUpload runat="server" ID="file" onchange="showimagepreview(this)" />--%><%-- onchange="CopyMe(this, this.id)"--%>
                                                                                        </td>
                                                                                    </tr>
                                                                                </table>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </itemtemplate>
                                                            
                                                        </td>
                                                        <td>
                                                            <table>
                                                                <tr>
                                                                </tr>
                                                                <td align="left" width="8%" style="padding-removed 5px;" valign="top">
                                                                    <asp:CheckBox runat="server" onClick="return visibility(this.id)" Text="image" ID="image" />
                                                                </td>
                                                                <tr>
                                                                    <td style="padding-removed 5px;">
                                                                        <asp:Button Text="AddMoreOptions" runat="server" ID="btnaddopt" OnClick="btnaddopt_Click" />
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="left" style="padding-removed 5px;">
                                                                        <asp:LinkButton ID="ClientButton" OnClientClick=" return v(this.id)" runat="server"
                                                                            Text="Add Question">
                                                                        <ajaxToolkit:ModalPopupExtender ID="mpe"  runat="server" BackgroundCssClass="modalBackground"
                                                                            TargetControlID="ClientButton" PopupControlID="ModalPanel" OkControlID="OKButton" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </itemtemplate>
Posted
Updated 29-May-14 20:14pm
v3
Comments
CHill60 29-May-14 9:58am    
What's in your page load event code behind?
Ranjeet Patel 29-May-14 10:41am    
Its difficult to say. because did not post the code Html. But I can tell that the full page may be posted back. If you are posting back a small part of your page then put the radio buttons outside the post back section of code.
JITHU.P 29-May-14 11:36am    
or can go to property of radio button and then turn the enable=true
VishwaKL 30-May-14 0:02am    
set Autopostback=true property for the radio button in aspx page
Awadhendra Tripathi 30-May-14 2:16am    
Check postback first ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900