0
我有以下標記爲用戶控件(.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);
}
其中SearchResult所是
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;
}
this.chkAdvSearchAllLibs.Checked
總是錯誤的,不管check-box
是否在頁面上被選中並被回發。
我不想重新加載頁面每次複選框的狀態變化,因此我並沒有設置支柱。但它現在的方式應該是有效的。我在這裏丟失了什麼?? :( – Programmerzzz
把它放在更新面板中,如果你不希望整個頁面回發 無法回發沒有回發的事件 – Kramb
正確,我知道UpdatePanel是一個選項)我正在檢查複選框狀態在Postback複選框預計將有它的狀態。甚至UpdatePanel回發,除了沒有頁面重新加載(ajax)我的問題是爲什麼它不起作用在第一個地方。我想 – Programmerzzz