disable master page updatepanel, allow client page updatepanel

Last post 12-10-2007 5:36 AM by Dhiraj@Pune. 6 replies.

Sort Posts:

  • disable master page updatepanel, allow client page updatepanel

    09-28-2007, 2:39 AM
    • Member
      178 point Member
    • drewex
    • Member since 11-15-2003, 4:33 AM
    • OC, CA
    • Posts 240

    Hi all,

     I have a master page which the content area is inside a update panel. This gives me option to create a site fully ajax enabled. I dont have to add this to every single page. This saves me bunch of time. I figured out how to call functions on master page and created this func below to disable the updatepanel. But this doesnt work i just cant disable it. Any ideas,

    Public Sub disableUpdatePanel(ByVal dis As Boolean)

    UpdatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional

    UpdatePanel1.ChildrenAsTriggers = False

    End Sub

     And as a second question is it possible to create a inner update panel while the parent one is disabled.

    Thanks

  • Re: disable master page updatepanel, allow client page updatepanel

    09-28-2007, 3:56 AM
    • Member
      264 point Member
    • SaloZaSolo
    • Member since 07-25-2007, 8:10 AM
    • Lebanon-Beirut
    • Posts 77

    greeeting there

    i dont know if i got  u right but its not the update panel that made ur site fully ajax enabled actually it has no functionality there

    the thing tht u can put in the master page that affect the functionality of the content pages is only the script manager where it gives its functionality to all the pages  that uses this master page

    second thing why disabling update panel while it has no use at all if u are tryin to load the pages in the content async thats not the way ul always c the content of the master page blinks (reload) and to be sure from that put break points on master .load where the page load function always triggered

     i dont know if i was usefull and helpfull please ask for further details........

    Salah Awad
  • Re: disable master page updatepanel, allow client page updatepanel

    09-29-2007, 1:31 AM
    • Member
      178 point Member
    • drewex
    • Member since 11-15-2003, 4:33 AM
    • OC, CA
    • Posts 240

    fyi this works:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

    <asp:ContentPlaceHolder ID="MainContent" runat="server">

    <asp:Panel ID="innerpanel" runat="server" Width="713px">

    </asp:Panel>

    </asp:ContentPlaceHolder>

    </ContentTemplate>

    </asp:UpdatePanel>

    I need is away to disable the updatepanel from acting.

  • Re: disable master page updatepanel, allow client page updatepanel

    10-04-2007, 5:05 AM
    Answer

    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,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
  • Re: disable master page updatepanel, allow client page updatepanel

    10-04-2007, 11:52 AM
    Answer
    • Member
      178 point Member
    • drewex
    • Member since 11-15-2003, 4:33 AM
    • OC, CA
    • Posts 240

    Actually sorry that i forgot  that i found a solution already. Disabling the script manager worked like a charm. The only bad part here is that i cant put a inner page update panel and script manager. Because its only allowed to add one script manager which make sense in javascript sense. If there was a option to disable the updatepanel it self and have another one inside of it would be nice but there is not. I'll post my code if any one wants to see it. Thanks for the replies tho.

  • Re: disable master page updatepanel, allow client page updatepanel

    10-04-2007, 11:35 PM

    Hi drewex,

    Are you disabling the script manager by setting "EnablePartialRendering = false" as i mentioned in the step3 in my last reply? It disable all updatepanels in the page.

    If you have better solution,sharing it will be very appreciated.

    Regards,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
  • Re: disable master page updatepanel, allow client page updatepanel

    12-10-2007, 5:36 AM
    • Member
      4 point Member
    • Dhiraj@Pune
    • Member since 12-06-2007, 11:42 PM
    • Posts 6

    Hi all, i am also facing the same Problem, my task is to build Ajax enabled website now i need to put Localization on Ajax, here is my code.

    <asp:ImageButton ID="ImgBtnFrance" runat="server" AlternateText="France" ImageUrl="~/images/FranceButton.JPG" OnClick="ImgBtnFrance_Click" meta:resourcekey="ImgBtnFranceResource1" />

    <asp:ImageButton ID="ImgBtnEnglish" runat="server" AlternateText="English" ImageUrl="~/images/EnglishButton.JPG" OnClick="ImgBtnEnglish_Click" meta:resourcekey="ImgBtnEnglishResource1" />

    <ajax:UpdatePanel ID="PanelPrints" UpdateMode="Conditional" runat="server">

    <ContentTemplate>

    <div style="vertical-align:top;">

    <asp:contentplaceholder id="BodySection" runat="server">

    </asp:contentplaceholder>

    </div>

    </ContentTemplate>

    </ajax:UpdatePanel>

    I hv two button and <ajax:update panel> on master page. i want to update it after clicking french button.code for french button on master page code behind

    on page load i have

    SMGRTry.RegisterAsyncPostBackControl(ImgBtnFrance);

    SMGRTry.RegisterAsyncPostBackControl(ImgBtnEnglish);

    PanelPrints.Update();

    protected
    void ImgBtnFrance_Click(object sender, ImageClickEventArgs e)

    {

    Session[
    Global.SESSION_KEY_CULTURE] = "fr-ca";Server.Transfer(Request.Path);

    }

    when i clicked french button it shows error "sys.webforms.pageRequestManagerParserErrorException"

    if anybody knows this error plz guide me.

Page 1 of 1 (7 items)