[英]CheckBox does not fire CheckedChanged event when unchecking the checkbox Dynamically in ASP.Net
Here I am having a checkbox in this update panel.在这里,我在此更新面板中有一个复选框。
<asp:UpdatePanel runat="server" ID="LVCheckBoxes">
<ContentTemplate>
<ul>
<li>
<asp:CheckBox ID="New" Text="New" AutoPostBack="true" runat="server" OnCheckedChanged="checkBoxCheck" /></li>
</ul>
</ContentTemplate>
</<asp:UpdatePanel >
All I am Trying to do is uncheck it on click of linkbutton.我要做的就是在单击链接按钮时取消选中它。 Which is working fine.
哪个工作正常。
<asp:LinkButton id="LbUnCheck" runat="server" OnClick="LbUnCheck" ToolTip="New">UnCheck</asp:LinkButton>
But Along with it I also want to fire the check changed Event Which is not firing但除此之外,我还想触发未触发的检查更改事件
protected void LbUnCheck(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
CheckBox cb = (CheckBox)LVCheckBoxes.FindControl(lb.ToolTip);
cb.CheckedChanged += checkBoxCheck;
cb.Checked = false;
}
protected void checkBoxCheck(object sender, EventArgs e)
{
//Do something
}
I even Tried this using JQuery but it is not working quite as expected.我什至使用 JQuery 进行了尝试,但它并没有像预期的那样工作。
Help Appreciated..!!帮助赞赏..!!
Try calling the CheckBox check event method ( checkBoxCheck
) from the Link Button click event method ( LbUnCheck
).尝试从链接按钮单击事件方法 (
LbUnCheck
) 调用 CheckBox 检查事件方法 ( checkBoxCheck
)。 Something like this:像这样的东西:
protected void LbUnCheck(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
CheckBox cb = (CheckBox)LVCheckBoxes.FindControl(lb.ToolTip);
// cb.CheckedChanged += checkBoxCheck; // REMOVE THIS LINE
cb.Checked = false;
checkBoxCheck(null, null); // NOTICE THIS IS AFTER SETTING cb.Checked = false;
}
protected void checkBoxCheck(object sender, EventArgs e)
{
//Do something
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.