Server. HTMLEncode enables the code to be displayed as source code on the page

Source: Internet
Author: User
This article describes how to display the html source code written to the database in the form of html source code on the page, this is a function in asp. Today, the html source code written to the database is displayed on the page in the form of html source code, rather than being interpreted by the browser .. After finding N for a long time, I don't know how to do it. then I can see that a program has the function of modifying the template .. I found a method named asp ^ and noted it down.

Server. HTMLEncode

HTMLEncode

1. the HTMLEncode method applies HTML encoding to the specified string.

Syntax
Server. HTMLEncode (string)

Parameters

String

Specifies the string to be encoded.
Example

Script

The code is as follows:


<% = Server. HTMLEncode ("The paragraph tag:

") %>


Output

The paragraph tag:

Note that the above output will be displayed

The paragraph tag:


If you look at the source file or open a Web page in text mode, you can see the encoded HTML

II. Analysis of related examples:

Rs ("content") = Server. Htmlencode (Request ("content ")):

Rs ("content") indicates that rs is a recordset object, and content is a field in the database table. The recordset object can operate each record in the database table, and each field.

Server. Htmlencode: converts some code into html format.

Request ("content") refers to the value of an element named content in the previous returned page. it may be a text box in the form, it may also be something of the querystring type.
But judging from the name and habits, it is a multi-line text box of a form, because it is used for content placement.
It puts the value in the text box sent from the previous submission page in the content field of the currently opened record in the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.