radpanelbar how to prevent postback

6 posts, 0 answers
  1. Richard
    Richard avatar
    9 posts
    Member since:
    May 2013

    Posted 15 May 2013 Link to this post

    hi,

    i have a radpanelbar, when i click the parent item or any sub item, the screen reloaded. 

    1. how do i prevent the screen from reload the whole page? 
    2. i have a radwindow open, when the screen reload or i press F5, the radwindow dissapear. how do i keep the radwindow open after refresh?

    thanks,
    Richard
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 May 2013 Link to this post

    Hi Richard,

    To prevent the whole page reloading you can either add the radpanelbar inside an updatepanel  or add the following js.
    1)
    Updatepanel method: ASPX
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
       <ContentTemplate>
           <telerik:RadPanelBar ID="RadPanelBar1" runat="server" OnItemClick="RadPanelBar1_ItemClick">
               <Items>
                         ... ... ...   
               </Items>
           </telerik:RadPanelBar>
       </ContentTemplate>
    </asp:UpdatePanel>
    OR
    Attach'OnClientItemClicking' client side event and add the following.
    JS:
    <script type="text/javascript">
      function OnClientItemClicking(sender, eventArgs)
      {
         eventArgs.set_cancel(true); // Cancel the postback
      }
    </script>

    2) To retain the window after screen reload set 'VisibleOnPageLoad' of radwindow as true.
    ASPX:
    <telerik:RadWindow ID="Window1" runat="server" VisibleOnPageLoad="true">
    </telerik:RadWindow>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tal
    Tal avatar
    22 posts
    Member since:
    May 2013

    Posted 29 Sep 2013 Link to this post

    Hi Princy,
    this is not quite understood.
    I tried what you wrote but as a consequence I can't click any item on the menu (method 2).
    I method 1 the whole page refreshes.

    thanks
  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 02 Oct 2013 Link to this post

    Hello,

    In order to avoid full post-back (whole page refresh) you can ajaxify the RadPanelBar control. You can achieve this functionality by simply using the RadAjaxManager as shown in the code snippet below:
    //markup code
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadPanelBar1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
    ....
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" OnItemClick="RadPanelBar1_ItemClick">
               ......
    </telerik:RadPanelBar>

    This will perform a post-back so any server-side logic will be executed but it will not refresh the whole page.


    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Tal
    Tal avatar
    22 posts
    Member since:
    May 2013

    Posted 03 Oct 2013 Link to this post

    Hi,
    I have this radpanel in my master page.
    I also need to have radAjaxManager on other pages  that use the same masterpage.

    How can I use these two together?
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Oct 2013 Link to this post

    Hi Tal,

    You can programmatically ajaxify the Master Page and Content Page controls. Please have a look into the following code snippet that I tried to ajaxify the Master Page Control in Content Page code behind. For more details please check this documentation.

    MasterPage ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" OnItemClick="RadPanelBar1_ItemClick">
        <Items>
            <telerik:RadPanelItem Text="Item1" runat="server">
                <Items>
                    <telerik:RadPanelItem Text="Item1.1" runat="server">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem Text="Item1.2" runat="server">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>

    Content Page C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadPanelBar panel = (RadPanelBar)Master.FindControl("RadPanelBar1");
        RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
        AjaxManager.AjaxSettings.AddAjaxSetting(panel, panel);
    }

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017