html - unable to get checked property of htmlinoutcheckbox on server side(code behind) -


i have created html input check-boxes dynamically code behind , after rendering check-boxes on aspx page i'm unable checked property of check-boxes on button click event. week enum alldays of week. here sample code.

htmlinputcheckbox chkbx = new htmlinputcheckbox(); chkbx.attributes.add("id", ((week)i).tostring()); chkbx.attributes.add("runat", "server"); chkbx.attributes.add("name", ((week)i).tostring()); chkbx.attributes.add("value", "checked");  htmlgenericcontrol label = new htmlgenericcontrol("label"); label.attributes.add("for", ((week)i).tostring()); if (i == 1 || == 7) {     label.attributes.add("class", "dow disabled");     label.attributes.add("disabled", "true"); } else {     label.attributes.add("class", "dow");     chkbx.checked = true;                     } label.innertext = ((week)i).tostring().substring(0,2); _dowcontrol.controls.add(chkbx); _dowcontrol.controls.add(label); 

aspx page

<body>     <form id="form1" runat="server" method = "post">         <t2:mycontrol id="samplecontrol" runat="server" >         </t2:mycontrol>     <asp:button id="button1" runat="server" text="button" onclick="button1_click" />     </form> </body> 

aspx.cs page should inside button click?

tried

request.form["***"], findcontrol("***") 

in order dynamically created controls interact viewstate, events , other stages in page life-cycle, need created in init event. creating these controls later in life-cycle exclude them taking part in post value binding, viewstate binding, etc. note must recreate controls on every postback.

protected void page_init(object sender, eventargs e) {     // dynamic control re/creation here. } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -