不使用的TargetControlID服务器控制 [英] Not using TargetControlID for server control

查看:222
本文介绍了不使用的TargetControlID服务器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用导致的弹出窗口2服务器控件。其一是pressing按钮原因。第二并不需要依赖于一个动作事件,但发生了编程。这里是code为第二:

I am using two server controls that cause popups. One is cause by pressing a button. The second does not need to depend on an action event but happens programatically. Here is the code for the 2nd:

<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>

有是附连到其不必须是第二个按钮。我并不需要它,它只是存在,因为如果我删除我得到的错误:

There is a button attached to the second one which does not have to be. I don't need it, it's just there because if I remove it I get errors:

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

我编程调用它:

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

我如何摆脱按钮,这样我就可以用这个特殊的服务器控件编程?

How do I get rid of the button so I can just use this particular server control programatically?

推荐答案

您可以将其分配给隐藏字段开始,然后以编程方式改变它在需要时所需的控制。

You could assign it to a hidden field initially, and then change it programmatically to the desired control when needed.

这篇关于不使用的TargetControlID服务器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆