Use the System.Web.UI.WebControls.Literal control to place literal text anywhere
on a Web Form.The ASPX page is as follows:
<html>
<head>
<title><asp:Literal id=”litTitle” runat=”server” /></title>
</head>
<body></body>
</html>
In <script runat=”server” /> block or codebehind:
Sub Page_Load(sender As Object, e As EventArgs)
litTitle.Text = “This is my page title.”
End Sub
The easiest way to place some content on a Web page when you want to have absolute
control over the formatting (for example, you don’t want your text wrapped in a <div>
tag or in other HTML tags) is to use the Literal control in the System.Web.UI.
WebControls namespace. Another option that you can use is data-binding, which you
use by adding <%# VariableName %> to the page and ensuring that Me.DataBind() is
called somewhere in the page’s execution (typically during Page_Load). Usually the
Literal is a better solution, however, because data-binding the page will force all the
controls on the page to data-bind as well, and this can cause unexpected results or inefficient
use of your controls.You can also use the LabelWeb Server Control to display
dynamic text.
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2008
(100)
-
▼
August
(7)
- Validating User Form Input in ASP.NET
- Displaying a Calendar in a Web Form in ASP.NET
- Selectively Hiding or Revealing Portions of a Web ...
- Creating a Scrolling Table within a Web Form in AS...
- Submitting Data to Another Page Using ASP.NET
- Dynamically Adding Literal Text or HTML to a Web F...
- Creating an ASP.NET Page
-
▼
August
(7)
No comments:
Post a Comment