How to implement Server.HTMLEncode to make the code appear as source code on the page
This article introduces the knowledge of "how to achieve Server.HTMLEncode to display the code as source code on the page". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Server.HTMLEncode
HTMLEncode
I. the HTMLEncode method applies HTML encoding to the specified string.
Grammar
Server.HTMLEncode (string)
Parameters.
String
Specifies the string to encode.
Example
Script
The copy code is as follows:
Output
The paragraph tag:
Note that the above output will be displayed by the Web browser as
The paragraph tag:
If you look at the source file or open a Web page as text, you can see the encoded HTML
two。 Analysis of relevant examples:
Rs ("content") = Server.Htmlencode (Request ("content")):
Rs ("content") means that rs is a recordset object, and content is a field in a database table; recordset objects can manipulate every record and every field in a database table.
The function of Server.Htmlencode: to convert some code into html format.
Request ("content") means that the last page returned has the value of an element named content; it may be a text box in the form, or it may be something of the querystring type.
But judging by name and habit, it is a multi-line text box of a form because it is used to place content.
The overall meaning is that it puts the value in the text box from the last submission page in the content field in the open record in the database.
This is the end of the content of "how to implement Server.HTMLEncode to display the code as source code on the page". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!