[英]Trying to make example work: How to use ASP.NET AJAX UpdatePanel in ModalPopup?
我发现这篇文章可以帮助我解决我目前遇到的问题。 问题是我正在努力让它发挥作用。 文章是如何在ModalPopup中使用ASP.NET AJAX UpdatePanel
所以我创建了一个更简单的例子,但问题是Label lblText
没有被更新(它仍然是这个标签 ),即使代码隐藏正在执行,因为它遇到了断点。 所以任何帮助都表示赞赏。
所以这是标记:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="udpOutterUpdatePanel" runat="server">
<ContentTemplate>
<div id="divControlContainer" runat="server">
<asp:LinkButton ID="lbtnRed" runat="server" onclick="lbtnRed_Click">Red</asp:LinkButton>
</div>
<input id="dummy" type="button" style="display: none" runat="server" />
<ajaxToolkit:ModalPopupExtender runat="server"
ID="mpeThePopup"
TargetControlID="dummy"
PopupControlID="pnlModalPopUpPanel" />
<asp:Panel ID="pnlModalPopUpPanel" runat="server" style="border: 2px solid black; position:absolute; width:600px; height: 520px; display:none">
<asp:UpdatePanel ID="udpInnerUpdatePanel" runat="Server" UpdateMode="Conditional">
<ContentTemplate>
<p>
<asp:DropDownList ID="ddlProducts" runat="server"></asp:DropDownList>
<asp:Button ID="btnChooseProduct" runat="server" Text="Choose" onclick="btnChooseProduct_Click"/>
<asp:Button ID="btnCancelModalPopup" runat="server" Text="Cancel" />
</P>
<div style="width: 200px; border: 1px solid red">
<asp:Label ID="lblText" Text="this is the label" ForeColor="Black" runat="server"></asp:Label><br />
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnChooseProduct" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
代码隐藏:
protected void btnChooseProduct_Click(object sender, EventArgs e)
{
lblText.Text = "You have selected " + ddlProducts.SelectedItem.Text;
//Show ModalPopup
mpeThePopup.Show();
}
protected void lbtnRed_Click(object sender, EventArgs e)
{
ddlProducts.Items.Clear();
//Populate DropDownList Items
ddlProducts.Items.Add(new ListItem("Red Balloon", "Red Balloon"));
ddlProducts.Items.Add(new ListItem("Red Apple", "Red Apple"));
ddlProducts.Items.Add(new ListItem("Red Shirt", "Red Shirt"));
ddlProducts.Items.Add(new ListItem("Red Watch", "Red Watch"));
mpeThePopup.Show();
}
问题是我在VS 2010中引用了AJAX Control Toolkit 3.5。我刚刚删除了该引用,下载并安装了AjaxControlToolkit.dll 4.0,现在一切正常。
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.