簡體   English   中英

回發后復選框狀態未更改

[英]Checkbox state not changed on postback

我對用戶控件(.ascx)進行了以下標記

<table>
<tr>
    <td>
        <asp:Label ID="Label1" runat="server" Text="Select Logical Symbol to 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 this box to search all available libraries" Text="Search All Libraries"/>
    </td>
</tr>
<tr>
    <td>
        <asp:Label ID="Label2" runat="server" Text="Search by Logical Symbol Properties:"></asp:Label>
    </td>
    <td>
    </td>
</tr>

頁面加載

protected void Page_Load(object sender, EventArgs e)
{
     SearchResults(ref attributeSearch, compTypeID);
}

SearchResults在哪里

 private void SearchResults(ref string attributeSearch, int compTypeID)
    {
        DataTable dtResults = this.AdvancedSearchControl.GetSearchResults(ref attributeSearch, compTypeID);
    }

在我的UserControl.ascx.cs中

public DataTable GetSearchResults(ref string _attrVals, int compTypeID)
{
                //Other Logic Goes Here
                IEnumerable<Model.ComponentInfo.ComponentType> compTypeResult = from compTypes in BLLibrary.GetComponentTypeBasedOnLib(this.CurrentLibraryId, this.CurrentLibrary, this.chkAdvSearchAllLibs.Checked) select compTypes.Value;
}

無論check-box是否在頁面上選中並回發, this.chkAdvSearchAllLibs.Checked始終為false。

服務器端:

將AutoPostBack =“ True”添加到復選框。 它沒有回發。

客戶端:

<asp:CheckBox runat="server" ID="cb" onclick="checkboxchanged(this);" />

function checkboxchanged( sender ) {
if ( sender.checked ) {
        // clicked and checked
    } else {
        // clicked and unchecked
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM