Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 794001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:14:42+00:00 2026-05-14T22:14:42+00:00

I have an ASP TextBox with TextMode set to MultiLine. I’m having problems with

  • 0

I have an ASP TextBox with TextMode set to MultiLine. I’m having problems with preserving the vbCrLf characters when a user tries to put line breaks into the text. When a button on the page is pressed, I’m taking the text from the control, trimming it using String.Trim, and assigning that value to a String property on an object (which, in turn assigns it to a private internal String variable on the object). The object then takes the value from the private internal variable and throws it into the database using a stored procedure call (the SP parameter it is put into is an nvarchar(4000)).

ASPX Page:

<asp:UpdatePanel ID="UpdatePanel2" runat="server" RenderMode="Inline" UpdateMode="Conditional"
                ChildrenAsTriggers="true">
  <ContentTemplate>
    <!-- some other controls and things -->
    <asp:TextBox TextMode="MultiLine" runat="server" ID="txtComments" Width="100%" Height="60px" CssClass="TDTextArea" Style="border: 0px;" MaxLength="2000" />
    <!-- some other controls and things -->
  </ContentTemplate>
</asp:UpdatePanel>

code behind:

ProjectRequest.StatusComments = txtComments.Text.Trim

object property:

Protected mStatusComments As String = String.Empty
Property StatusComments() As String
  Get
    Return mStatusComments.Trim
  End Get
  Set(ByVal Value As String)
    mStatusComments = Value
  End Set
End Property

stored proc call:

  Common.RunSP(mDBConnStr, "ProjectStatusUpdate", _
    Common.MP("@UID", SqlDbType.NVarChar, 40, mUID), _
    Common.MP("@ProjID", SqlDbType.VarChar, 40, mID), _
    Common.MP("@StatusID", SqlDbType.Int, 8, mStatusID), _
    Common.MP("@Comments", SqlDbType.NVarChar, 4000, mStatusComments), _
    Common.MP("@PCTComp", SqlDbType.Int, 4, 0), _
    Common.MP("@Type", Common.TDSqlDbType.TinyInt, 1, EntryType))

Here’s the strangest part. When I debug the code, if I type

“test
test”

(without the quotes) into the comments text box, then click the save button and use the immediate window to view the variable values as I step through, here is what I get:

?txtComments.Text
"test test"
?txtComments.Text.Trim
"test
test"
?txtComments.Text(4)
"
"c
?txtComments.Text.Trim()(4)
"
"c

Anyone have a clue as to what’s going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:14:43+00:00Added an answer on May 14, 2026 at 10:14 pm

    There are two problems at bay here. First, the immediate window in VB is converting the non-printable character to a space so you cannot see it. In C#, it will show the character using its replacement escape code (e.g. \n or \r\n), but VB does not. Second, VB sees the break as a line-feed only (vbLf) not a carriage-return+line-feed (vbCrLf). Thus, if you do the following in break mode in the immediate window you will see what I mean (assuming you type test, hit Enter, test in the comments box):

    ?txtComments.Text.Substring(4,1) = vbLf
    True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.