RadMultiPage Javascript Control

3 posts, 0 answers
  1. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 05 Jun 2009 Link to this post

    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. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 11 Jun 2009 Link to this post

    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.
  3. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 11 Jun 2009 Link to this post

    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.
Back to Top