onClientTabSelected JavaScript Error

2 posts, 0 answers
  1. ataxia1
    ataxia1 avatar
    16 posts
    Member since:
    May 2007

    Posted 23 Jul 2008 Link to this post

    Trying to use an IF statement to determine which tab was clicked, but I keep receiving a javaScript error, "Object cannot be converted to string"

            strPopUpScript = strPopUpScript & "function ClientTabSelected(sender, args) {" & vbCrLf  
            strPopUpScript = strPopUpScript & "  var tab = args.get_tab();" & vbCrLf  
            strPopUpScript = strPopUpScript & "//  if (tab.get_text() == 'New User') {" & vbCrLf  
            strPopUpScript = strPopUpScript & "//    var oWnd = $find(" & RadWindow1.ClientID & ");" & vbCrLf  
            strPopUpScript = strPopUpScript & "//    oWnd.setUrl('MyPage.aspx');" & vbCrLf  
            strPopUpScript = strPopUpScript & "//    oWnd.show();" & vbCrLf  
            strPopUpScript = strPopUpScript & "//  }" & vbCrLf  
            strPopUpScript = strPopUpScript & "  alert(tab.get_text());" & vbCrLf  
            strPopUpScript = strPopUpScript & "}" & vbCrLf 

    With the IF commented out, the name of the tab displays perfectly.  With the IF in play, the system exception pops.  Tried every variation of .toString, String( ), passing tab.get_text() into another variable first, and nothing seems to work.  Any suggestions?

    Thanks,

    - Brad
  2. ataxia1
    ataxia1 avatar
    16 posts
    Member since:
    May 2007

    Posted 24 Jul 2008 Link to this post

    Found the problem.  The example script posted on the support site is missing apostrophes in the $find statement.  Here's working code:

            strPopUpScript = strPopUpScript & "function ClientTabSelected(sender, args) {" & vbCrLf  
            strPopUpScript = strPopUpScript & "  var tab = args.get_tab();" & vbCrLf  
            strPopUpScript = strPopUpScript & "  if (tab.get_text() == 'New User') {" & vbCrLf  
            strPopUpScript = strPopUpScript & "    var oWnd = $find('" & RadWindow1.ClientID & "');" & vbCrLf  
            strPopUpScript = strPopUpScript & "    oWnd.show();" & vbCrLf  
            strPopUpScript = strPopUpScript & "  }" & vbCrLf  
            strPopUpScript = strPopUpScript & "}" & vbCrLf 
Back to Top