Why doesn't c# find the attribute? asp.net

piempohotiamn

New Member
I have 4 checkboxes, below each checkbox is a div. Each checkbox is responsible for showing or hiding the checkbox that is below it.for example: \[code\] <asp:CheckBox ID="CheckBox1" myDiv="divRegisteration" myText=" ????? - " runat="server" AutoPostBack="true" Font-Size="18px" Font-Bold="true" Text=" ????? - ???" OnCheckedChanged="CheckBox_CheckedChanged"/> <div id="divRegisteration" runat="server" visible="false">\[/code\]the checkbox 'CheckBox1' is responsible for showing or hiding the div "divRegisteration", which is addressed in the custom attribute "myDiv".problem is, in the code behind, it does not find the attribute "myDiv":\[code\]if (((CheckBox)(sender)).Checked==true){ CheckBox chk = (CheckBox)(sender); object div = FindControl(chk.Attributes["myDiv"]); //// it does not find myDiv, and therefore doesn't find the control so the program crashes. HtmlGenericControl addressDiv = (HtmlGenericControl)(div); addressDiv.Visible = true; }\[/code\]
 
Back
Top