Prevent 'Chr(13) + Chr(10)' from Being Executed in String

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Prevent 'Chr(13) + Chr(10)' from Being Executed in String

    I have the following code in my web page.

    Dim tmpReplace As String
    'Giving tmpReplace the value from the textbox on the
    webform.
    tmpReplace = txtComments.Text.Trim
    'Prevents report from crashing when a single quote is in
    string
    tmpReplace = tmpReplace.Replace("'", "''")
    'Replace carriage return with the appropriate CharCodes.
    tmpReplace = tmpReplace.Replace("\n", "chr(13) + chr(10)")

    I want to display the following text on my report: chr(13) + chr(10)
    Instead what is happening is that .Net is executing the chr function
    and creating a carriage return. What do I need to do to prevent the
    chr function from being launched?
    crjunk Guest

  2. Similar Questions and Discussions

    1. Can a .as be executed in CF8
      IIRC you can use the import and #include directives using cfformitem type="script" and/or cfsavecontent. Though I do not know if either is...
    2. a different web.config gets executed
      I have .Text running on a Windows 2003 Server website, and a WebService project running on the same website, but in a virtual directory created...
    3. hoe to prevent a control from being executed
      I have 2 controls on this page as shown below. The first is a datalist control which contains links to the particular image gallery (second...
    4. aspnet_wp won't get executed
      Hi folks.. I installed windows server 2003 with domain controller role. And installed iis6 and .net framework etc. I run aspnet_regiis -i for...
    5. how to prevent prevent .so-calling routine to crash from segfaults in .so
      Hi, Guys I am stuck with a problem and need some help. Platform : Linux(RedHat 7.3) Problem Area : Dynamic Shared Object Libraries, POSIX...
  3. #2

    Default Re: Prevent 'Chr(13) + Chr(10)' from Being Executed in String

    | tmpReplace = tmpReplace.Replace("'", "''")
    | 'Replace carriage return with the appropriate CharCodes.
    | tmpReplace = tmpReplace.Replace("\n", "chr(13) + chr(10)")
    |
    | I want to display the following text on my report: chr(13) + chr(10)
    | Instead what is happening is that .Net is executing the chr function
    | and creating a carriage return. What do I need to do to prevent the
    | chr function from being launched?

    It's not executing the Chr function. "\n" is not special character i VB.NET.
    If you want to replace CRLF, use:

    tmpReplace = tmpReplace.Replace(vbCrLf, "chr(13) + chr(10)")

    But if you're doing this only for storing in database, use parameters
    instead and everything - quotes, line ends etc. - would be escaped
    automatically.

    --
    Michal A. Valasek, Altair Communications, [url]http://www.altaircom.net[/url]
    Please do not reply to this e-mail, for contact see [url]http://www.rider.cz[/url]


    Michal A. Valasek Guest

  4. #3

    Default Re: Prevent 'Chr(13) + Chr(10)' from Being Executed in String

    I removed the "\n" from the code. The example I was using to go by
    said this would remove the return, but obviously it wont. Here is what
    I changed it to.

    Here is code from my report options page:

    'Setup user's comments in correct format so that it can be
    'passed to the comment formula on the report.

    Dim tmpReplace As String

    tmpReplace = txtComments.Text.Trim

    'Replace double quotes in the string with 2 double quotes.
    tmpReplace=tmpReplace.Replace(Chr(34), Chr(34) + Chr(34))

    'Replace carriage returns & line feed with double quotes &
    'text that represents a return and line feed.
    tmpReplace = tmpReplace.Replace(Chr(13) + Chr(10), """ +
    chr(13) + chr(10) + """)

    'Add double quotes to tmpReplace.
    tmpReplace = """" + tmpReplace + """"

    Session("UComments") = tmpReplace

    This allows me to pass the text to my web form that contains my
    CrystalReport Viewer. On this page, I have the following text:

    oRpt.DataDefinition.FormulaFields.Item("UserCommen ts").Text
    = Trim(Session("UComments"))
    CrystalReportViewer1.ReportSource = oRpt

    By doing this I can pass the value to a blank formula field named
    UserComments on my report. Took forever, but I finally got everything
    to work.
    crjunk Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139