Results 1 to 4 of 4

Thread: Carriage Returns

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80

    Question 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

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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>"
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80
    I tried & vbcrlf but when I ran my code I got an error saying that vbcrlf was not declared. Do you know why?

    James

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    You need to either

    imports microsoft.VisualBasic

    or reference it directly as

    microsoft.VisualBasic.vbCrLf
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width