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

[Solved] RadMultiPage Javascript Control

2 Answers 154 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 05 Jun 2009, 10:16 PM
Hello,

I could use a little assistance here since I can't seem to figure this out. Here's what I'm trying to achieve...

I have a RadMultiPage with 2 pages inside a .NET LoginView control. In the AnonymousView, PageView1 has a link called Login. When clicked, I need to switch to PageView2 using JavaScript. I need to do it this way instead of an AJAX callback because I want to set a timer to switch back to PageView1 after a certain amount of time.

My issue right now is that I can't seem to figure out how to access the RadMultiPage in JavaScript when it's inside the LoginView control.

Can someone explain to me how to do that? Thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 11 Jun 2009, 01:23 PM
Hi Philip,

The FindControl method provides you with a reference to any control. You must make sure that you properly typecast the returned value as FindControl returns a reference to a Control class. For detailed information on the subject please make a search in MSDN.

Kind regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Philip Senechal
Top achievements
Rank 1
answered on 11 Jun 2009, 05:10 PM
Yes...I finally figured it out, but I also had to make sure to put it inside a conditional statement in the code behind, otherwise it would throw an object not found error after logging in since the MultiPage is in the anonymous template. Here's the coding if anyone is interested...

If Context.User.Identity.IsAuthenticated Then 
     Dim firstName As Label = TryCast(LoginView1.FindControl("FirstName"), Label)  
     Dim lastName As Label = TryCast(LoginView1.FindControl("LastName"), Label)  
     firstName.Text = Profile.FirstName  
     lastName.Text = Profile.LastName  
Else 
     Dim loginPage As RadMultiPage = TryCast(LoginView1.FindControl("RadMultiPage1"), RadMultiPage)  
     Dim scriptString As String = "" 
     scriptString += "<script type=""text/javascript"">" 
     scriptString += "function loginView_Show() {" 
     scriptString += "var loginPage = $find('" & loginPage.ClientID & "');" 
     scriptString += "loginPage.set_selectedIndex(1);" 
     scriptString += "setTimeout('loginView_Hide();',30000)" 
     scriptString += "}" 
     scriptString += "function loginView_Hide() {" 
     scriptString += "var loginPage = $find('" & loginPage.ClientID & "');" 
     scriptString += "loginPage.set_selectedIndex(0);" 
     scriptString += "}" 
     scriptString += "</script>" 
     Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "loginView", scriptString)  
 
     Dim loginBtn As LinkButton = TryCast(loginPage.FindControl("loginBtn"), LinkButton)  
     loginBtn.Attributes.Add("onClick""setTimeout('usernameGetFocus();',500)")  
End If 

In my Master Page, there's a JavaScript function to set the focus to the username text box...

<script type="text/javascript">  
 
     function usernameGetFocus() {  
          $get("userName").focus();  
     }  
 
</script> 

Hope this helps anyone looking to do the same thing.
Tags
TabStrip
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Paul
Telerik team
Philip Senechal
Top achievements
Rank 1
Share this question
or