0

我正在使用两个导致弹出窗口的服务器控件。一种是按下按钮引起的。第二个不需要依赖于动作事件,而是以编程方式发生。这是第二个的代码:

<div>
    <ajaxToolkit:ModalPopupExtender ID="ModalPopupChangeAssociations" runat="server" TargetControlID="Button1" PopupControlID="changeAssociationsPanel"
        PopupDragHandleControlID="PopupHeader" Drag="true">
    </ajaxToolkit:ModalPopupExtender>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:Panel ID="changeAssociationsPanel" runat="server" CssClass="changeAssociationsPanel">
        <h2>This theme type is currently assigned to themes. What would you like to do?</h2>
        <asp:Button ID="removeAssignmentButton" runat="server" Text="Remove all Associated Assignments"
            OnClick="removeAssignmentButton_Click" />
        <asp:Button ID="changeAssignmentButton" runat="server" Text="Change all Associated Assignments"
            OnClick="changeAssignmentButton_Click" />
        <asp:Button ID="cancelAssignmentButton" runat="server" Text="Cancel" OnClick="cancelAssignmentButton_Click" />
        <asp:Panel ID="reassignPanel" runat="server" Visible="false">
            <asp:Label ID="reassignThemeTypeLabel" runat="server" Text="New Theme Type:"></asp:Label>
            <asp:DropDownList ID="reassignThemeTypeDropDown" runat="server" DataSourceID="SqlDataSource2"
                DataTextField="Type" DataValueField="PK_ThemeType">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                SelectCommand="SELECT [Type], [PK_ThemeType] FROM [ThemeType] WHERE [Deleted] = 0 ORDER BY [Type] ASC"></asp:SqlDataSource>
            <asp:Button ID="reassignThemeTypeSubmitButton" runat="server" Text="Submit" OnClick="reassignThemeTypeSubmitButton_Click" />
        </asp:Panel>
    </asp:Panel>
</div>

第二个按钮附有一个按钮,但不必如此。我不需要它,它就在那里,因为如果我删除它,我会收到错误:

The TargetControlID of 'ModalPopupChangeAssociations' is not valid. The value cannot be null or empty.

我以编程方式调用它:

        if (checkIfAssociationExist(sqlQueryReturnString(getThemeTypePK)))
        {
            ModalPopupChangeAssociations.Show();
        }

如何摆脱按钮,以便我可以通过编程方式使用这个特定的服务器控件?

4

2 回答 2

1

您最初可以将其分配给隐藏字段,然后在需要时以编程方式将其更改为所需的控件。

于 2013-10-02T19:06:19.277 回答
1

不过我不确定,您可以使用标签作为目标 ID。如果没有标签,那么您可以添加标签并将可见属性设置为 false。

于 2013-10-02T19:13:08.820 回答