试图使示例工作:How to use ASP.NET AJAX UpdatePanel in ModalPopup?
Trying to make example work: How to use ASP.NET AJAX UpdatePanel in ModalPopup?
我发现这篇文章可以帮助我解决目前遇到的问题。问题是我很难让它发挥作用。文章是How to use ASP.NET AJAX UpdatePanel in ModalPopup
所以我创建了一个更简单的示例,但问题是 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,现在一切正常。
谢谢。
我发现这篇文章可以帮助我解决目前遇到的问题。问题是我很难让它发挥作用。文章是How to use ASP.NET AJAX UpdatePanel in ModalPopup
所以我创建了一个更简单的示例,但问题是 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,现在一切正常。
谢谢。