Reputation: 399
I have a problem with the following code block:
Dim scriptHere As System.Web.UI.HtmlControls.HtmlGenericControl = control.Page.FindControl("scriptHere")
Dim controlID As String = ""
Dim disabled As String = IIf(isDisabled, "true", "false")
If TypeOf (control) Is ASPxEditBase Then
controlID = control.ID
End If
Try
control.ReadOnly = isDisabled
Dim script As String = ""
script &= "<script type=""text/javascript"">" & vbCrLf
script &= "// <![CDATA[" & vbCrLf
script &= "try {" & vbCrLf
script &= "$('#<%= " + controlID + ".ClientID %>').attr('disabled', " + disabled + ");" & vbCrLf
If selectedIndex <> -1 Then
control.SelectedIndex = selectedIndex
script &= "" + controlID + ".SetValue(" + selectedIndex.ToString() + ");" & vbCrLf
End If
script &= "} catch (e) { " & IIf(showErrors, "alert(e.message);", ";") & " }" & vbCrLf
script &= "// ]]> " & vbCrLf
script &= "</script>" & vbCrLf
scriptHere.InnerHtml &= script
Catch ex As Exception
Console.Out.WriteLine(ex.ToString())
End Try
The problem is, that it throws me an Exception. To be more precise it just says "Undefined" and nothing else. I figured that the problem lies within this line:
script &= "$('#<%= " + controlID + ".ClientID %>').attr('disabled', " + disabled + ");" & vbCrLf
Furthermore, with this being a jQuery command i can assume that the Exception is caused by the "$".
Extra Info:
jQuery(document).ready(function ()
{/.../});
That's all for now. Thanks in advance.
Upvotes: 0
Views: 213
Reputation: 1318
Ok, see if this would work -
script &= "$('#" + controlID.ClientID + "').attr('disabled', " + disabled + ");" & vbCrLf
It looks like the inline VB isn't pulling out the correct client id, but you've already got it server-side, so you should be able to build the entire script string up in one go.
Upvotes: 1