This is a migrated thread and some comments may be shown as answers.

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

4 Answers 149 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Claus
Top achievements
Rank 2
Claus asked on 12 Aug 2013, 02:17 PM
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.

4 Answers, 1 is accepted

Sort by
0
Claus
Top achievements
Rank 2
answered on 12 Aug 2013, 07:38 PM

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 :-)
0
TonyG
Top achievements
Rank 1
answered on 03 Dec 2013, 07:52 AM
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.
0
priyadarshini
Top achievements
Rank 1
answered on 19 Jan 2016, 08:19 AM

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

0
Eyup
Telerik team
answered on 22 Jan 2016, 08:00 AM
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
Tags
TabStrip
Asked by
Claus
Top achievements
Rank 2
Answers by
Claus
Top achievements
Rank 2
TonyG
Top achievements
Rank 1
priyadarshini
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or