This question, should be a very simple question, can say really, toss 2 hours of time, after the whole out of time, really pit dad. Now give this process to everybody, hope can give everybody a reminder.
First, vb.net ASP. NET Problem restore
When I edited a piece of data, we entered the edit page, such as the Work Araound field in the following page
I've filled in some of these fields. I went through the carriage and broke into a paragraph, but when we saved the edit page, the results were as follows:
You can see clearly that the displayed value is not segmented. The display effect is very unfriendly.
Solution:
Keywords: vbCrLf (because the project needs, so the use of vb.net and VS2005, so that everyone laughed), I get through the following code to every time you enter the car, and then I get to the carriage return, and then change into a "|", so put into the database. (In fact, there is a disadvantage, that is, "|" has become an unavailable character. )
Copy Code code as follows:
Dim Strtextarea As String = Replace (Textarea1.value, vbCrLf, "|") this sentence is equivalent to the following: Dim Strtextarea As String = TextArea1.Value.Re Place (vbCrLf, "|")
Then, when we read it from the database, we're replacing it with the following:
Copy Code code as follows:
Label1.Text = Strtextarea.replace ("|", "<br>")
And then, here's the basic OK. In the middle of the time around, we seem to have the desired results.
In fact, there is another problem, that is, when each is a long time, the following bug will appear. See, the field beyond the line is not done, it is difficult to see.
This we need to add a style to the current element's parent element OK, that's word-break:break-all, and then the line will be automatically wrapped.
Copy Code code as follows:
<TD style= "WIDTH:451PX; Word-break:break-all ">
<textarea id= "txtreleasenotecomment" cols= "WU" rows= "a" runat= "Server" visible= "false" ></textarea>
<asp:label id= "lbl_releasenotedcomment" runat= "Server" text= "" visible= "False" width= "450px" ></asp:label >
</TD>
The results shown are as follows:
Comment on: Feeling, around a curved. However, the first so use it, anyway, first submitted to say!
Second, C # ASP. Net of the situation?
That's a lot easier to deal with. Environment: VS 2010
Test code:
Copy Code code as follows:
<asp:textbox id= "TextBox1" runat= "Server" height= "105px" textmode= "MultiLine"
Width= "320px" ></asp:TextBox>
<asp:button id= "Button1" runat= "Server" onclick= "Button1_Click" text= "button"/>
<br/>
<asp:label id= "Label1" runat= "Server" text= "Label" ></asp:Label>
And then, we set a breakpoint on the button,
Look above, I did not set anything, automatically recognized the line symbol: \ r \ n, then the next very good deal with:
Copy Code code as follows:
protected void Button1_Click (object sender, EventArgs e)
{
Label1.Text = TextBox1.Text.Replace ("\ r \ n", "<br>");
}
It's OK.
It's OK.
Third, Winform
That in the WinForm, that is simpler, you do not need to deal with the value of the direct assignment to the textbox OK.
Copy Code code as follows:
Label1. Text = TextBox1.Text;
Eh You have to feel the technology advanced OH.