本文介绍了模式弹出不产生回发到页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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
文件:
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";
}
我不希望页回发所有,但一旦进入信息只是为了更新页面上的隐藏的标签。我该怎么做呢?
I do not want the page to post back at all, but just to update the hidden labels on the page once information is entered. How do I do this?
推荐答案
编辑:
好吧,这应该做的伎俩,我认为。
Alright, this should do the trick I think.
<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();
}
这篇关于模式弹出不产生回发到页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!