我已经调查了这个问题。我相信您在子页面 (aspx) 中有更新面板,在母版页中有消息 div。更新面板可以更新位于其下方的控件,但无法更新位于更新面板之外的控件。因此,您需要将更新面板放在母版页中。
在母版页中
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div><strong>Demo for master page updation</strong></div>
<div id="divMaster" runat="server">
I am div in master page, going to change with ajax call
</div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
在内容页面 (.aspx)
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
在后面的内容页面代码 (.aspx.cs)
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000); //To check the effect of ajax call, must be removed
HtmlGenericControl divMaster = (HtmlGenericControl) this.Master.FindControl("divMaster");
divMaster.InnerHtml = "hello I am being change from child page";
}