How to select a Tab from a User Control inside a PageView as an AJAX request

5 posts, 0 answers
  1. Claus
    Claus avatar
    2 posts
    Member since:
    Jan 2013

    Posted 12 Aug 2013 Link to this post

    Hello there,
    I'd like to select a tab with a button located inside a user control which is then located inside a RadPageView element, i.e.
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" Width="720"  SelectedIndex="1">
      <telerik:RadPageView ID="RadPageView1" runat="server" Selected="true">
        <uc1:DoctorControl ID="DoctorControl" runat="server" />
      </telerik:RadPageView>
    ...

    and inside the DoctorControl I have a button to be hooked up with an event handler.

    However, I can't figure out how to do this in an "ajaxified way".
    I want the tab selection to behave in the same way as if I click the tabs directly, i.e. an AJAX request is initiated and the RadAjaxLoadingPanel is shown during the request.

    Obvisously the RadAjaxManager of the page hosting everything can't see the actual initiator which is a button hidden inside the user control,
    so this is part of the problem.

    Anyone know how to achieve this ?

    Thanks
    Claus

    PS. I am using the Telerik example TabStrip / Application Scenarios / AJAX-Enabled TabStrip and MultiPage as a starting point.
  2. Claus
    Claus avatar
    2 posts
    Member since:
    Jan 2013

    Posted 12 Aug 2013 Link to this post

    Okay the solution was actually quite logical.

    The button of the user control must to be registered with the RadAjaxManager programatically, i.e.:

        protected void Page_Load(object sender, EventArgs e)
        {
            RadAjaxManager ram = (RadAjaxManager)this.Parent.FindControl("RadAjaxManager1");
            RadTabStrip rts = (RadTabStrip)this.Parent.FindControl("RadTabStrip1");
            RadMultiPage rmp = (RadMultiPage)this.Parent.FindControl("RadMultiPage1");
            RadComboBox rcb = (RadComboBox)this.Parent.FindControl("RadComboBox1");
            RadAjaxLoadingPanel ralp = (RadAjaxLoadingPanel)this.Parent.FindControl("LoadingPanel1");
     
            ram.AjaxSettings.AddAjaxSetting(Button2, rmp, ralp);
            ram.AjaxSettings.AddAjaxSetting(Button2, rcb);
            ram.AjaxSettings.AddAjaxSetting(Button2, rts);
    ...

    and the Button2 click event:
    protected void Button2_Click(object sender, EventArgs e)
    {
        RadTabStrip rts = (RadTabStrip)this.Parent.FindControl("RadTabStrip1");
        rts.Tabs[1].Selected = true;
        rts.Tabs[1].PageView.Selected = true;
    }

    and everything works as it desired :-)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 03 Dec 2013 Link to this post

    I was just challenged to do something almost identical. Thanks for the tip. We see notes like this around the forum and docs but your example is very focused.

    This whole area can be very confusing.
    - Do we reference the controls? RadAjaxPanels surrounding the controls?
    - Do we tell the parent to handle the details or do we make parent controls visible to the child user controls?
    - Do we try to make use of RadAjaxManagerProxy?

    You made your decisions and mine were similar but over time I'd like to experiment with various options to try to achieve more elegance.
  5. priyadarshini
    priyadarshini avatar
    1 posts
    Member since:
    Dec 2015

    Posted 19 Jan in reply to Claus Link to this post

    Hi Claus,

    Its working fine,but when we click on other tabs ,the tabs are getting selected but it displays the same pageview which we selected in the code behind file

  6. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 22 Jan Link to this post

    Hello Priyadarshini,

    Please make sure that you implement the AjaxSettings for RadTabStrip and RadMultiPage as demonstrated here:
    http://www.telerik.com/help/aspnet-ajax/ajax-tips-and-tricks.html


    Also, please temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017