javascript - 一旦 Enabled 设置为 false,即使在将其设置回 true 后,用户控件中的确认按钮扩展器也不起作用
问题描述
我有一个用户控件,其中包含一个确认按钮扩展器和一个模式弹出扩展器。看起来像:
<asp:Panel ID="panelConfirmBox" runat="server" Style="display:none;">
<asp:Button ID="btnConfirmSelection" runat="server" CssClass="hidden"/>
<asp:Button ID="btnNo" runat="server" Text="No" />
<asp:Button ID="btnYes" runat="server" Text="Yes" />
<asp:ModalPopupExtender Id="popupConfirmBox" runat="server" PopupControlID="panelConfirmBox" CancelControlID="btnNo" OkControlId="btnYes" />
<asp:ConfirmButtonExtender ID="btnConfirm" runat="server" DisplayModalPopupID="popupConfirmBox"/>
</asp:Panel>
用户控件获得一个下拉列表。更改下拉列表选择时,应运行按钮 onclick 事件。在用户控件 aspx.cs 中有以下代码:
public string TargetControlId { set { popupConfirmBox.TargetControlID = btnConfirm.TargetControlID = btnConfirmSelection.ID; } }
public DropDownList DDL { get; set; }
public EventHandler OnClick { set { btnConfirmSelection.Click += value; } }
public bool Enabled { set { btnConfirm.Enabled = value; } get { return btnConfirm.Enabled; } }
protected void Page_Load(object sender, EventArgs e)
{
if (DDL != null)
{
string script = "$('#" + DDL.ClientID + "').on('change', function () { $('#" + btnConfirmSelection.ClientID + "').click();}); ";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "CallChange" + ID, script, true);
}
}
在 aspx 中使用用户控件如下所示:
<asp:DropDownList ID="ddl" runat="server" AutoPostBack="false" />
<aa:DDLConfirmPopup runat="server" ID="ConfirmPopupSelectionChange" Title="aaa" Message="bbb" TargetControlId=""/>
在 aspx.cs 中:
ConfirmPopupSelectionChange.DDL = ddl;
ConfirmPopupSelectionChange.OnClick = new EventHandler(func);
protected void func(object sender, EventArgs e)
{
}
我有几个用户控件的实例,除了一个之外,大多数都可以正常工作。一旦我设置了属性 Enabled="false",即使我将其设置回 true,它也不会再次显示弹出窗口,而是直接转到 onClick 函数。这是更改启用属性的函数:
private void manageConfirmPopup()
{
if (---)
ConfirmPopup.Enabled = true;
else
ConfirmPopup.Enabled = false;
}
我看到 enable 属性确实更改正确,但即使将其设置为 true,confirm 也不起作用。
我的代码有什么问题?
谢谢!
解决方案
推荐阅读
- angular - Send an action with file contents in NgRx / Angular 7
- pandas - 取消堆叠单列数据框
- arrays - Julia: delete rows and columns from an array or matix
- flutter - 如何在颤动中获得数字的 n 次方(数字的平方或立方等)?
- html - ngbDropdownMenu.close() on multiple dropdowns
- python - 为什么 sum 函数不正确地舍入两个浮点数
- django - 如何在 Zappa (wkhtmltopdf) 中安装 OS 依赖包
- python - 按特定轴过滤元组列表
- java - 在使用 material.textfield.TextInputLayout 时,我的轮廓框涵盖了提示。如何在不覆盖我的盒子的情况下显示提示?
- r - `mstate`:将“long”格式数据准备成“mstate”格式数据