In this section we study three controls, they are: HiddenField, Literal, and LinkButton.
We use LinkButton for the demonstration here, because this control is similar to BUTTON in usage, but it looks a bit strange. Maybe the controls are open-minded, and HyperLink and Button are blind. The result is LinkButton, but don't tell me, although it came out with such an unfair name, its contribution is very good, so it must be praised!
We first learn HiddenField, which provides a The method is used to store information on the page, and the usage is similar to other control information, but it does not display it. Speaking of which, by the way, don’t think it’s okay if it doesn’t display it. You still don’t store sensitive information such as passwords in it. information because it is visible in the HTML source of the page.
LinkButton
Next, let’s talk about Literal: We don’t use this control much, or even rarely, but since Microsoft has made it, we have an obligation to talk about it to avoid being said to be unkind. Besides, this was only released in 2.0. A new thing, haha!!!
I'm too lazy to type, so I copied something from MSDN
. The Literal control represents one of several options for adding content to the page. For static content, there is no need to use a container and the markup can be added directly to the page as HTML. However, if you want to add content dynamically, you must add the content to the container. Typical containers include Label control, Literal control, Panel control and Placeholder control.
The difference between a Literal control and a Label control is that the Literal control does not add any HTML elements to the text. (The Label control renders a span element.) Therefore, the Literal control does not support any style properties, including position properties. However, the Literal control allows you to specify whether the content should be encoded.
Panel and Placeholder controls are rendered as div elements, which creates discrete blocks in the page, unlike the way Label and Literal controls are rendered inline.
Typically, literal controls are used when you want text and controls to be rendered directly on the page without any additional markup.
Literal controls support a Mode property, which specifies how the control handles markup that you add. You can set the Mode property to the following values:
Transform . Any markup added to the control will be converted to suit the protocol of the requesting browser. This setting is useful if you are rendering content to mobile devices that use protocols other than HTML.
PassThrough. Any markup added to the control will be rendered in the browser as-is.
Encode. Any markup added to the control will be encoded using the HtmlEncode method, which converts the HTML encoding to its textual representation. For example, the <b> tag will be rendered as <b>. Encoding is useful when you want the browser to display the markup without interpreting it. Encoding is also useful for security, helping to prevent malicious markup from being executed in the browser. This setting is recommended when displaying strings from untrusted sources.
Transform mode is used
-------------------------------------------------- ----------------------------------
[fdsf](desf);"hahah"
PassThrough mode is used
-------------------------------------------------- ----------------------------------
[fdsf](desf);"hahah"
Encode mode is used
<hr><i>[fdsf](desf);"hahah"<br><p></i>
This is the normal mode Label
-------------------------------------------------- ----------------------------------
[fdsf](desf);"hahah"
This is the way to decode using the Server.HtmlEncode method
<hr><i>[fdsf](desf);"hahah"<br><p></i>