Master Page, User Control and Partial Postback

2 posts, 0 answers
  1. Robin
    Robin avatar
    41 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2012 Link to this post

    Hello everyone, 

    I'm very new to telerik controls, ajax and asp.net. And I have been stacked with this for several days. 
    I'm having a problem with Master Page and Partial Postback from UserControls.
    My objective is to show alert to user one minute before session was expired by redirecting to prepared page..
    I implemented it by Refreshing Warning page with desired time interval.
    I added following line at Page_Load event of MasterPage to refresh and show warning one minute before timeout.

    Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60) + ";URL=ExtendSession.aspx");

    This is AjaxManager Manager Code block from MasterPage.
    <telerik:RadAjaxManager ID="ajaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cboShortCut">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="cboShortCut" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    At ExtendSession.aspx, I used javascript to show countdown timer and ask user to Extend or Logout.
    Everything works fine if I open new aspx page, timer was reset.
    But it was not reset when something was changed from UserControl inside aspx pages.
    Example, OnSelectedIndexChange event of RadComboBox does not reset the timer.
    This is part of markup page for RadComboBox from UserControl.
    <telerik:RadAjaxManagerProxy ID="ajaxmanagerproxy" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cboTest">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="cboSubTest" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="cboSubTest2" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="lblValue" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
         </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:AjaxSetting AjaxControlID="ajaxManager">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="uploadAssetImg" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="cboTest" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="cboOthers" UpdatePanelRenderMode="Inline" />
                </UpdateControls>
    </telerik:AjaxSetting>

    ...

    <telerik:RadComboBox ID="cboTest" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cboTest_SelectedIndexChanged" />

    I tried to change PageHeader of MasterPage by adding following line at LoadEvent from BaseClass of UserControls.

    protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                if (this.Page.Master.AppRelativeVirtualPath == "~/MasterPage.Master")
                {
                    Page l_CurrentPage = HttpContext.Current.CurrentHandler as Page;
                    MasterPage l_MasterPage = (MasterPage)l_CurrentPage.Master;
                    l_MasterPage.Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60) + ";URL=ExtendSession.aspx");
                }
            }

    But unfortunately, MasterPage was not reset and ended with following error message with its time's up :(

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 
    Requested URL: /ExtendSession.aspx, 60;URL=ExtendSession.aspx

    Please help guys.
    I think this is partial postback. Is there a way to handle partial postback at MasterPage?
    Is my approach is incorrect? Or is there any way to change PageHeader of MasterPage from UserControl?
    Or is there any setting at RadAjaxManager to handle partial postback?

    Please let me know if my provided information are not enough.
    Thanks in advanced.
    Thant Sin Lin
  2. Robin
    Robin avatar
    41 posts
    Member since:
    Sep 2012

    Posted 28 Nov 2012 Link to this post

    Oh....Yes!

    I solved by using Javascript and OnRequestStart event of Telerik Ajax Manager without refreshing MasterPage Header.
    Thanks.
Back to Top