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

Server Side Selected Tab

16 Answers 369 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Kavya
Top achievements
Rank 2
Kavya asked on 19 Jun 2008, 05:44 PM




Hi

I did check forums but couldn't find right solution
I am trying to change the color of the Selected Tab.I know i can go and change it in Css file .
However my scenario is i have 5 tabs 
and each  navigate to different page when i click on tab i am not using NavigateURL instead i am using RadTabStrip Click

The Issue is it doesn't tell me which tab i clicked and RadTabStrip is in web usercontrol and i have autopostback=true

so please do let me know ho i can tell which one is the selected tab



Protected Sub RadTabStrip1_TabClick(ByVal sender As Object, ByVal e As Telerik.WebControls.TabStripEventArgs) Handles RadTabStrip1.TabClick  
 
        Dim radTabClickedRowIndex As Integer  
 
 
        radTabClickedRowIndex = Convert.ToInt32(Request.Form("radTabClickedRowIndex"))  
        Select Case e.Tab.Text  
            Case "Name"  
'Tried this didn't work  
                RadTabStrip1.SelectedTab.BackColor = Drawing.Color.Blue  
                Response.Redirect("xyz.aspx", True)  
 
        End Select  
    End Sub 





16 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Jun 2008, 11:21 AM
Hello Kavya ,

You should change the background color when the new page has been loaded (inside the PageLoad event for example). However you need a way to determine which tab was clicked. Using the query string is one way to solve that task:

Response.Redirect("xyz.aspx?SelectedTab=RadTabStrip1.SelectedTab.Text" & , True) 

Then in the Page_Load event you can determine the current tab like this:

Dim tab as RadTab = RadTabStrip1.FindTabByText(Request.QueryString("SelectedTab"))
If Not tab Is Nothing Then
    tab.BackColor = Color.Blue
End If

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kavya
Top achievements
Rank 2
answered on 23 Jun 2008, 02:43 PM
Hello Albert

I did try the code you gave me but no luck
In the page_load event eventhough i have th correct value in Request.QueryString("SelectedTab"))
when i use findbyText it gives me nothing even if i try findbyvalue it shows the text correctly but then is shows selected = false.

I have autopostback= True do you think that's reason its not giving me the right value .

Thanks
Kavya
0
Atanas Korchev
Telerik team
answered on 23 Jun 2008, 03:03 PM
Hello Kavya ,

The tab will not appear as selected - you need to select it from codebehind in Page_Load. The reason is that you have navigated to a new page and RadTabStrip state is reset.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kavya
Top achievements
Rank 2
answered on 23 Jun 2008, 03:09 PM
Hello Albert

I am useing request.querystring in Page Load itself but still doesn't work 

Dim tab as RadTab = RadTabStrip1.FindTabByText(Request.QueryString("SelectedTab"))
If Not tab Is Nothing Then
    tab.BackColor = Color.Blue
End If

should the above code go in  the page_load of the new page or in the same page where radtabstrip is created because in the new page RadTabStrip1will not be recognised .

I know it might be something simple but i am  missing some information.

Thanks
Kavya
0
Atanas Korchev
Telerik team
answered on 24 Jun 2008, 05:53 AM
Hi Kavya ,

This code should be put in the Page_Load method of every page which contains RadTabStrip.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kavya
Top achievements
Rank 2
answered on 25 Jun 2008, 02:19 PM
Hi

RadTabStrip is in WebUserControl i tried the code you sent me but no luck

Below is the code i am using 

 
 
<radTS:Tab ID="tab4" Width="100px" Text="Confirm Name" Value="tab4" runat="server" ></radTS:Tab> 
 
 
 
 
In the Code Behind  
 
 
Protected Sub RadTabStrip1_TabClick(ByVal sender As Object, ByVal e As Telerik.WebControls.TabStripEventArgs) Handles RadTabStrip1.TabClick  
 
 
Select Case e.Tab.Text  
 
Case "Confirm Name"  
 
RadTabStrip1.SelectedTab.BackColor = Drawing.Color.Blue  
 
Response.Redirect("xyz.aspx?selectedtab='" & RadTabStrip1.SelectedTab.Text & "'", True)  
 
End Select  
 
End Sub  
 


So please let me know where i am goin wrong 
0
Atanas Korchev
Telerik team
answered on 26 Jun 2008, 06:41 AM
Hi Kavya ,

Your code is the same as in the first place. You don't seem to have added the selection code in Page_Load. Please give it a try:

Dim tab as RadTab = RadTabStrip1.FindTabByText(Request.QueryString("SelectedTab"))
If Not tab Is Nothing Then
    tab.BackColor = Color.Blue
    tab.Selected = True
End If


Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kavya
Top achievements
Rank 2
answered on 02 Jul 2008, 09:46 PM
Hi Albert

Sorry for the delay

I have been working on something else
I tried to copy the code you sent and pasted it in the Page_load of the page where its navigated
it gives me error near radtab it doesn't recognize that
And also radstrip1 is in different control page so its not recognizing even that

So please let me know
0
Accepted
Atanas Korchev
Telerik team
answered on 03 Jul 2008, 06:30 AM
Hello Kavya ,

I guess you are having compliation errors? Please resolve them by importing the required namespace. Also I cannot understand the following "And also radstrip1 is in different control page so its not recognizing even that". Please provide more details about your scenario. In a word the code I've sent you the last time should solve your request - you need to make it compile and obtain a reference to the RadTabStrip control.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kavya
Top achievements
Rank 2
answered on 03 Jul 2008, 03:27 PM
hi Albert

Thanks for the information there was single quotes which i was adding to the string that was the reason it wasn't recongnizing

Thanks for resolving my issue.

Kavya


0
vivek
Top achievements
Rank 1
answered on 11 Nov 2010, 08:20 AM
I have three RadTab .
TAB1
TAB2
TAB3

when i click on TAB1 it opens google.com
when i click on TAB2 it opens msn.com
when i click TAB3 it opens MSN.

While traversing from one TAB to other. There is a javascript error. Could you please help me to resolve this issue. My Application call different url at different TAB and while clicking any TAB I am getting the JAvasript error. I didnt use script in my application.
0
Kavya
Top achievements
Rank 2
answered on 11 Nov 2010, 03:46 PM

Vivek

Can you post the javascript error. Are you using navigate URL or calling different pages in codebehind

kavya

0
vivek
Top achievements
Rank 1
answered on 12 Nov 2010, 05:02 AM
Hi Kavya,

Thank you for you response.Below are the detailed description for my error.

I am opening the url into the frame when i click the TABS  like

 

Me.IFrame1.Attributes("src") = "htto://www.google.com"

 

Me.IFrame2.Attributes("src") = "htto://www.msn.com"

A javascript error popup is comming.
"A runtime error has occured.
 Do you want to debug.
Line 7 Invalid Argument"

When i choose "debug"  i can see a new dynamic javascript file "ext-all.js" and the error  is on the line u.height=o  saying invalid argument.

I am wondering from where this .js file is  coming and how do i solve this problem?

Thanks in advance. Your answer will be helpful to me.

 

0
Princy
Top achievements
Rank 2
answered on 12 Nov 2010, 10:36 AM
Hello Vivek,


In your case, a better approach is setting the iframe url from client side. Attach the 'OnClientTabSelected' event, access the iframe control, set the src accordingly.

Client code:
function OnClientTabSelected(sender, args) {
    var tab = args.get_tab();
    if (tab.get_text() == "Tab1") {
        document.getElementById("iframe1").src = "http://www.msn.com";
    }
    else if (tab.get_text() == "Tab2") {
        document.getElementById("iframe2").src = "http://www.google.com";
    }
}




Thanks,
Princy.
0
vivek
Top achievements
Rank 1
answered on 12 Nov 2010, 10:46 AM

 

HI Princy,

I have implimented your appraoch. Every thing goes well but the frame of google or MSN is not visible . Frame is blank. NO data is there inside the IFrame.When i debug the JS, i can see the page into the outerHTML of the frame. But final UI become blank.
Need ur advice
0
vivek
Top achievements
Rank 1
answered on 12 Nov 2010, 11:39 AM
HI Princy,

I have implimented your appraoch. Every thing goes well but the frame of google or MSN is not visible . Frame is blank. NO data is there inside the IFrame.When i debug the JS, i can see the page into the outerHTML of the frame. But final UI become blank.
Need ur advice
Tags
TabStrip
Asked by
Kavya
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Kavya
Top achievements
Rank 2
vivek
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or