模态弹出不生成回发到页面

本文关键字:模态 | 更新日期: 2023-09-27 18:02:55

<ajaxToolkit:ModalPopupExtender  runat="server" 
         id="ModalPopupExtender1"
         cancelcontrolid="btnCancel" okcontrolid="btnOkay" 
         targetcontrolid="Button1" popupcontrolid="Panel1" 
         drag="true" 
         backgroundcssclass="ModalPopupBG"
        />
<asp:Button ID="Button1" runat="server" Text="Test Modal Popup" 
    onclick="Button1_Click" />
    <br />
<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
        <asp:Button ID="Button2" runat="server" Text="Post Back" 
        onclick="Button2_Click" />
        <asp:Label ID="Label1" runat="server" AutoPostBack="true" Text="Nothing has happened yet..."></asp:Label>
        <asp:Panel ID="Panel1" runat="server" AutoPostBack="true">
            <div class="HellowWorldPopup">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:Button ID="btnCancel" runat="server" Text="Canel" 
                    onclick="btnCancel_Click" />
                <asp:Button ID="btnOkay" runat="server" Text="Okay" onclick="btnOkay_Click" />
            </div>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>

所以我试图让标签有什么用户在模态弹出框内输入的文本框的内容。现在btnOkay不能使此工作。

.cs file:

protected void btnCancel_Click(object sender, EventArgs e)
{
    TextBox1.Text = "";
}
protected void btnOkay_Click(object sender, EventArgs e)
{
    Label1.Text = TextBox1.Text;
    TextBox1.AutoPostBack = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
    Label1.Text = "";
    TextBox1.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
    Label1.Text = "You clicked the button";
}

我不希望页面张贴回来,但只是更新页面上的隐藏标签一旦信息被输入。我该怎么做呢?

模态弹出不生成回发到页面

编辑:好了,我想这应该可以了。

<ajax:ModalPopupExtender runat="server" id="ModalPopupExtender1" targetcontrolid="Button1"
    popupcontrolid="Panel1" drag="true" backgroundcssclass="ModalPopupBG"  />
<asp:Button ID="Button1" runat="server" Text="Test Modal Popup" /><br />
<asp:Panel ID="Panel1" runat="server">
    <div class="HellowWorldPopup">
        <asp:TextBox ID="TextBox1" runat="server" />
        <asp:Button ID="btnCancel" runat="server" Text="Canel" onclick="btnCancel_Click" />
        <asp:Button ID="btnOkay" runat="server" Text="Okay" onclick="btnOkay_Click" />
    </div>
</asp:Panel>
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Nothing has happened yet..." />
    </ContentTemplate>
</asp:UpdatePanel>

.

protected void btnCancel_Click(object sender, EventArgs e)
{
    TextBox1.Text = ""; 
}
protected void btnOkay_Click(object sender, EventArgs e)
{
    Label1.Text = TextBox1.Text;
    up.Update();
}