Server-side Comments
Example:
<Script Runat="Server">
Dim strSomeText As String
Sub Page_Load
strSomeText = "Hello!"
End Sub
</Script>
<html>
<head><title>ServerComments.aspx</title></head>
<body>
<form Runat="Server">
<%--
This is inside the comments
<asp:Label Text="hello!" Runat="Server" />
<%= strSomeText %>
--%>
This is outside the comments
</form>
</body>
</html>
- We can add comments to ASP.NET pages by using server-side comment blocks.
- The beginning of a server-side comment is marked with the characters <%-- and the end of the comment is marked with the characters --%>.
- Server-side comments can be added to a page for the purposes of documentation.
- We cannot see the contents of server-side comment tags, unlike normal HTML comment tags, by using the View Source command on Web browser.
- Server-side comments can also be useful when we are debugging an ASP.NET page.
- We can temporarily remove both ASP.NET controls and code render blocks from a page by surrounding these elements with server-side comments.
Example:
<Script Runat="Server">
Dim strSomeText As String
Sub Page_Load
strSomeText = "Hello!"
End Sub
</Script>
<html>
<head><title>ServerComments.aspx</title></head>
<body>
<form Runat="Server">
<%--
This is inside the comments
<asp:Label Text="hello!" Runat="Server" />
<%= strSomeText %>
--%>
This is outside the comments
</form>
</body>
</html>
No comments:
Post a Comment