-
Carriage Returns
I have the following code in my Page_load event. Can someone tell me how I can add carriage returns at the end of each line of my javascript string? When VB renders the HTML I want my javascript to look nice. At the moment my javascript is written on one line.
Dim sScript As String
sScript = "<script language=javascript> "
sScript += "Function Wait(agr)"
sScript += "{"
sScript += "document.body.style.cursor='wait';__doPostBack(agr, '');"
sScript += "}"
sScript += "function __doPostBack(eventTarget, eventArgument)"
sScript += "{"
sScript += "var theform = document._ctl0;"
sScript += "theform.__EVENTTARGET.value = eventTarget;"
sScript += "theform.__EVENTARGUMENT.value = eventArgument;"
sScript += "theform.submit();"
sScript += "</script>"
If (Not IsClientScriptBlockRegistered("MyScript")) Then
RegisterClientScriptBlock("MyScript", sScript)
End If
Company.Attributes.Add("onChange", "Wait('Company','');")
Thanks
James
-
Code:
Dim sScript As String
sScript = "<script language=javascript> " & vbcrlf
sScript += "Function Wait(agr)" & vbcrlf
sScript += "{" & vbcrlf
sScript += "document.body.style.cursor='wait';__doPostBack(agr, '');" & vbcrlf
sScript += "}" & vbcrlf
sScript += "function __doPostBack(eventTarget, eventArgument)" & vbcrlf
sScript += "{" & vbcrlf
sScript += "var theform = document._ctl0;" & vbcrlf
sScript += "theform.__EVENTTARGET.value = eventTarget;" & vbcrlf
sScript += "theform.__EVENTARGUMENT.value = eventArgument;" & vbcrlf
sScript += "theform.submit();" & vbcrlf
sScript += "</script>"
-
I tried & vbcrlf but when I ran my code I got an error saying that vbcrlf was not declared. Do you know why?
James
-
You need to either
imports microsoft.VisualBasic
or reference it directly as
microsoft.VisualBasic.vbCrLf