<summary>
Replace special characters in HTML
</summary>
<param name= "TheString" > Text that needs to be replaced. </param>
<returns> Replace the finished text. </returns>
public string HtmlEncode (string thestring)
{
Thestring=thestring.replace (">", ">");
Thestring=thestring.replace ("<", "<");
Thestring=thestring.replace ("", " ");
Thestring=thestring.replace ("", " ");
Thestring=thestring.replace ("/" "," " ");
Thestring=thestring.replace ("/", "& #39;");
Thestring=thestring.replace ("n", "<br/>");
return thestring;
}
How to input a large section of text in the page text into the database format and read from the database to restore the format
Xiaomaoxia (a little bee flying in the Bushes) Grade: Knot Rate: 100% |
Landlord posted on: 2002-10-22 17:03:44
The format simply refers to carriage returns, blanks, etc., If a code is entered, it is executed when it is read out from the database and displayed. How to deal with. |
|
|
|
It worked for me. [0] lost a brick [0] cited report management top reply number: 0--> |
Xiaomaoxia (a little bee flying in the Bushes) rank: |
#1楼 Score: 0 reply to: 2002-10-22 17:16:21
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Sanniko (Goose title mud) Grade: |
#2楼 Score: 10 reply to: 2002-10-22 17:18:27
First you want to make sure that the conversion of the characters such as ' <> return space is so that you can write to the database, and then the display will be converted to the corresponding switch. |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Xiaomaoxia (a little bee flying in the Bushes) rank: |
#3楼 Score: 0 reply to: 2002-10-22 17:22:51
Example String test; String test1; Test=test. Replace ("", " ") How to replace the carriage return ... |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Gangganghao (Ganggang) Grade: |
#4楼 Score: 10 reply to: 2002-10-22 17:24:11
If it is a multiline text box input ... Show in multiline text box ... Do not need to do the processing. If it is not displayed in a multiline text box Replace CHR &CHR (10) in Server.HTMLEncode (database content) with <br> Replace Chr (32) &CHR with With replace
What code do you mean by code. of HTML.
|
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Thinkway (Thinkway) Grade: |
#5楼 Score: 10 reply to: 2002-10-22 17:50:16
Enter. Replace "n" with "<br>" on the line. |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Xiaomaoxia (a little bee flying in the Bushes) rank: |
#6楼 Score: 0 reply to: 2002-10-23 09:01:37
Gold near: <br>     Defangjun   Card Tunnel Bureau guilty of a fine      military proliferation local officers ,   labor Law import   <br>           & nbsp Card strike Law   Ah, dead hangar  .
This is what I saved in the database after I replaced it, read it out of the database and show it on the page: Gold near: <br>     Defangjun   Card Tunnel Bureau guilty of a fine      military proliferation local officers ,   labor Law import   <br>           & nbsp Card strike Law   Ah, dead hangar  .
^_^, what should I do? |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Xiaomaoxia (a little bee flying in the Bushes) rank: |
#7楼 Score: 0 reply to: 2002-10-23 09:04:46
Add: The following is the panel,html code to display the content <asp:panel id= "Panel1" runat= "server" font-names= "italics _gb2312" font-size= "Small" height= "175px" Wid Th= "750px" forecolor= "Black" horizontalalign= "left" > <%=forcontent%> <font face= "song Body" size= "3 "> </FONT> </asp:panel>
Forcontent is a content variable read from the database
Also, can you display the format in the page with a panel?
I've never done this before. |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Thinkway (Thinkway) Grade: |
#8楼 Score: 10 reply to: 2002-10-23 10:01:04
Do not replace it in the database, and replace it in the read data. If you make two replacements, you'll be back soon. Again, data is data, and if your data is to be displayed in Windows instead of on a Web page, it's not a mess. |
|
|
Useful to me [0] throw a brick [0] Quote report Management Top |
Thinkway (Thinkway) Grade: |
#9楼 Score: 30 Reply to: 2002-10-23 10:05:17
This could help you ... CS function to translate text into HTML documents: Textparser.parser (string text, bool allow) Using System; Using System.Text; Using System.IO; Namespace Website.support { public class Textparser { Public Textparser () { // Todo:add constructor Logic here // } method to parse Text into HTML public string Parser (string text, bool allow) { Create a StringBuilder object from the string intput parameter StringBuilder sb = new StringBuilder (text); Replace all double white spaces and Sb. Replace ("", " "); Check if HTML tags are not allowed if (!allow) { Convert the brackets into HTML equivalents Sb. Replace ("<", "<"); Sb. Replace (">", ">"); Convert the double quote Sb. Replace ("/", """); } Create a StringReader from the processed string of the StringBuilder object StringReader sr = new StringReader (sb. ToString ()); StringWriter SW = new StringWriter (); Loop while next character exists while (Sr. Peek () >-1) { Read a line from the string and store it to a temp variable String &n |
|