Literal Text and HTML Tags
Example :
<Script Runat="Server">
Sub Page_Load
Dim litControl As LiteralControl
For each litControl in Page.Controls
litControl.Text = strReverse( litControl.Text )
Next
End Sub
</Script>
<html>
<head><title>Literal.aspx</title></head>
<body>
<b>This text is reversed</b>
</body>
</html>
- The final type of element that WE can include in an ASP.NET page is HTML content.
- The static portion of page is built with plain old HTML tags and text.
- HTML content in a page is represented with the LiteralControl class.
- We can use the Text property of the LiteralControl class to manipulate the pure HTML portion of an ASP.NET page.
Example :
<Script Runat="Server">
Sub Page_Load
Dim litControl As LiteralControl
For each litControl in Page.Controls
litControl.Text = strReverse( litControl.Text )
Next
End Sub
</Script>
<html>
<head><title>Literal.aspx</title></head>
<body>
<b>This text is reversed</b>
</body>
</html>
- The HTML content contained in the page is reversed when it is displayed .
- The Page_Load subroutine walks through all the controls in a page (including the LiteralControl) and reverses the value of the Text property of each control.
No comments:
Post a Comment