gpt4 book ai didi

c# - 模态弹出窗口不生成回传到页面

转载 作者:太空宇宙 更新时间:2023-11-04 16:19:53 25 4
gpt4 key购买 nike

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

所以我试图让 Label 包含用户在模式弹出窗口中的文本框中键入的内容。现在 btnOkay 没有导致它工作。

.cs 文件:

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();
}

关于c# - 模态弹出窗口不生成回传到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6776540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com