Hi,
Based on my understanding, you want to set ChildrenAsTriggers property of the updatepanel in the masterpage to "False" from content page. Why do you want to do this? I think the answer is that you just want that same content pages can fire the updatepanel rather than all content pages, don't you?
So I think the best solution is add the updatepanel to the masterpage from content page that need updatepanel and scriptmanager. See Is it possible to add a ScriptManager and/or UpdatePanel to a MasterPage from a ContentPage dynaically? for this solution.
If you persist in your "solution"(set ChildrenAsTriggers = false), I am afraid you cann't do it. I have tested with the following steps:
Step1:
MasterPage.master:
<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Default.aspx:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}
protected void Page_PreInit(object sender, EventArgs e)
{
//HtmlForm form1 = (HtmlForm)Master.FindControl("form1");
//UpdatePanel panel = (UpdatePanel)form1.FindControl("UpdatePanel1"); ;
UpdatePanel panel = (UpdatePanel)Master.FindControl("UpdatePanel1"); ;
panel.UpdateMode = UpdatePanelUpdateMode.Conditional;
panel.ChildrenAsTriggers = false;
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button inside the inner updatepanel" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" Text="Button outside the inner updatepanel" OnClick="Button1_Click" />
</asp:Content>
It is supposed the Button2 fire a sync-postback, but not, it still fire a async-postback, if you place a breakpoint at "TextBox1.Text = DateTime.Now.ToString();", you will see it be executed. So i know Button2 still fire a async-postback rather than sync-postback or no postback, and the async-postback don't refresh the content.
So i want to test if button still fire asyncpostback when the updatepanel is set UpdateMode="Conditional" ChildrenAsTriggers="false", see step2.
Step2:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button inside the inner updatepanel"
OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
With this step,I found button still fire asyncpostback when the updatepanel is set UpdateMode="Conditional" ChildrenAsTriggers="false". So your solution don't work.
Step3:
Change the masterpage to the following can disable the PartialRendering,but it disable all updatepanels in the page(include outer and inner).
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}
protected void Page_PreInit(object sender, EventArgs e)
{
//HtmlForm form1 = (HtmlForm)Master.FindControl("form1");
//UpdatePanel panel = (UpdatePanel)form1.FindControl("UpdatePanel1"); ;
ScriptManager sm = (ScriptManager)Master.FindControl("ScriptManager1");
sm.EnablePartialRendering = false;
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button inside the inner updatepanel" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" Text="Button outside the inner updatepanel" OnClick="Button1_Click" />
</asp:Content>
I think the best solution is add the updatepanel to the masterpage from content page that need updatepanel and scriptmanager.
May this can help you too: How to register a WebService from a User Control
Best Regards,