<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";
}
我不希望页面完全回发,只是在输入信息后更新页面上的隐藏标签。我该怎么做?
答案 0 :(得分:1)
编辑: 好吧,这应该是我认为的伎俩。
<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();
}