我正在使用两个导致弹出窗口的服务器控件。一种是按下按钮引起的。第二个不需要依赖于动作事件,而是以编程方式发生。这是第二个的代码:
<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();
}
如何摆脱按钮,以便我可以通过编程方式使用这个特定的服务器控件?