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

onClientTabSelected JavaScript Error

1 Answer 56 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
ataxia1
Top achievements
Rank 1
ataxia1 asked on 24 Jul 2008, 01:56 AM
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

1 Answer, 1 is accepted

Sort by
0
ataxia1
Top achievements
Rank 1
answered on 24 Jul 2008, 12:12 PM
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 
Tags
TabStrip
Asked by
ataxia1
Top achievements
Rank 1
Answers by
ataxia1
Top achievements
Rank 1
Share this question
or