[英]radiobutton checked status on asp:linkbutton postback
我在中繼器控件中有四個單選按鈕,該控件本身在更新面板中
//代碼是這樣的
`<asp:update panel ..>
...
<asp:Repeater>
..
<asp:checkbox>
..
..
</asp:update panel ..>
<asp:LinkButton ID="next2" runat="server" CssClass="button_Submit" Font-Bold="true" OnClick="next_ServerClick" Text="Submit">
<asp:ImageButton ID="next" ImageUrl="~/images/newSummary.jpg" runat="server" OnClick="next_ServerClick" ImageAlign="Middle"/>
protected void next_ServerClick(object sender, EventArgs e)
{
foreach (System.Web.UI.WebControls.RepeaterItem Item in repeatercontrol.Items)
{
chkbox = ((CheckBox)Item.FindControl(chkboxName));
if (chkbox.checked)
{
...
}
}
}`
我選擇其中一個復選框,當我單擊“圖像”按鈕時,便能夠獲得正確的狀態(選中= true)。
但是,當我使用鏈接按鈕時,它總是以選中= false的形式出現,好像選擇沒有注冊。
為什么會這樣?
您需要在更新面板中將linkbutton click事件注冊為觸發器。 請參見下面的示例:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButtonID" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.