c# - Checkbox state not changed on postback -
i have following mark user control (.ascx)
<table> <tr> <td> <asp:label id="label1" runat="server" text="select logical symbol search:"></asp:label> </td> <td> <asp:dropdownlist id="ddlcomponenttype" runat="server" onselectedindexchanged="ddlcomponenttype_selectedindexchanged" autopostback="true"> </asp:dropdownlist> </td> <td> <asp:checkbox id="chkadvsearchalllibs" runat="server" tooltip="check box search available libraries" text="search libraries"/> </td> </tr> <tr> <td> <asp:label id="label2" runat="server" text="search logical symbol properties:"></asp:label> </td> <td> </td> </tr>
on page load
protected void page_load(object sender, eventargs e) { searchresults(ref attributesearch, comptypeid); }
where searchresults is
private void searchresults(ref string attributesearch, int comptypeid) { datatable dtresults = this.advancedsearchcontrol.getsearchresults(ref attributesearch, comptypeid); }
and in usercontrol.ascx.cs
public datatable getsearchresults(ref string _attrvals, int comptypeid) { //other logic goes here ienumerable<model.componentinfo.componenttype> comptyperesult = comptypes in bllibrary.getcomponenttypebasedonlib(this.currentlibraryid, this.currentlibrary, this.chkadvsearchalllibs.checked) select comptypes.value; }
this.chkadvsearchalllibs.checked
false no matter if check-box
checked on page , posted or not.
server side:
add autopostback="true" checkbox. it's not posting back.
client side:
<asp:checkbox runat="server" id="cb" onclick="checkboxchanged(this);" /> function checkboxchanged( sender ) { if ( sender.checked ) { // clicked , checked } else { // clicked , unchecked } }
Comments
Post a Comment