弹出面板,回发问题

时间:2011-08-30 14:03:06

标签: c# asp.net popup ajaxcontroltoolkit modalpopupextender

我有一个面板作为弹出窗口

 <asp:Panel ID="CreateGroupPanel" runat="server" BackImageUrl="~/Light-Gray-Suede1.jpg" 
        CssClass="style10" Visible="True" 

        style="position: absolute; left: 214px; top: 1262px; width: 588px; height: 467px">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
         </asp:ToolkitScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

         <ContentTemplate>
        <asp:Label ID="Label3" runat="server" CssClass="style11" Text="Group Name*" 

            style="position: absolute; left: 63px; top: 92px; width: 88px; height: 19px; background-image: url('Light-Gray-Suede1.jpg')"></asp:Label>
        <asp:Label ID="Label4" runat="server" CssClass="style12" Text="Members*" 

            style="position: absolute; left: 67px; top: 278px; width: 66px; height: 19px; background-image: url('Light-Gray-Suede1.jpg')"></asp:Label>
        <asp:Label ID="Label5" runat="server" CssClass="style9" 
            Text="Groups | + Create group" 
            style="background-image: url('Light-Gray-Suede1.jpg')"></asp:Label>
        <asp:Label ID="Label6" runat="server" CssClass="style13" 
            style="background-image: url('Light-Gray-Suede1.jpg'); position: absolute; left: 63px; top: 130px; width: 80px; height: 19px;" 
            Text="Add user(s)*"></asp:Label>
        <asp:TextBox ID="GroupName" runat="server" CssClass="style109" 


            style="position: absolute; left: 170px; top: 91px; width: 135px; height: 22px"></asp:TextBox>
        <asp:Button ID="Create" runat="server" CssClass="style106" 
            onclick="Create_Click" 
            style="background-image: url('Light-Gray-Suede1.jpg')" 
            Text="Create Group" />
        <asp:Button ID="Cancel" runat="server" CssClass="style107" Text="Cancel" 
            onclick="Cancel_Click" 
            style="background-image: url('Light-Gray-Suede1.jpg')" />
        <asp:Button ID="Add" runat="server" CssClass="style108" OnClientClick="Add_Click" 
            style="background-image: url('Light-Gray-Suede1.jpg')" 
            Text="Add" />

        <asp:ListBox ID="ListBoxMembers" runat="server" CssClass="style105"></asp:ListBox>
        <asp:ListBox ID="ListBoxREmoved" runat="server" CssClass="style104"></asp:ListBox>
        <asp:Button ID="Button1" runat="server" CssClass="style103" 
            onclick="Button1_Click" Text="Remove&gt;&gt;" />

        <asp:Listbox ID="ListBoxAddMembers" runat="server" CssClass="style102" 
            DataSourceID="SurelyKnown" DataTextField="FirstName" DataValueField="FirstName"></asp:ListBox>

    <asp:SqlDataSource ID="SurelyKnown" runat="server" 
            ConnectionString="<%$ ConnectionStrings:surelyknownConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:surelyknownConnectionString.ProviderName %>" 
            SelectCommand="SELECT FirstName FROM tbl_user"></asp:SqlDataSource>

    </ContentTemplate>
     </asp:UpdatePanel>


</asp:Panel>

当我单击面板中的添加按钮以将值从列表框添加到文本框时,面板会因为单击添加按钮而返回回发,因此弹出窗口已关闭。(但是当我再次单击时按钮打开弹出按钮执行添加方法并添加值)如何从列表框中添加值到文本框而不弹出窗口

2 个答案:

答案 0 :(得分:0)

尝试为更新面板设置ChildrenAsTrigger="false"并指定显式触发器。

答案 1 :(得分:0)

如果您还没有,我会在UpdatePanel中放置Panel和ModalPopupExtender(假设您正在使用AJAX Toolkit),并且正如Bala R建议尝试将ChildrenAsTrigger设置为false。

使用更新面板,即使按钮单击事件仍然导致弹出窗口关闭,您也可以在按钮单击事件中重新打开它,它将对用户显示无缝,因为它全部通过Ajax完成。