Server Side Comments with ASP.NET 2.0
In ASP.net application, we can comment
the HTML code by,
<!-- HTML Comments
-- >
When we do this, the browser will omit
displaying the contents between <!—-and --> block but the actual
contents inside this block will be parsed, executed by the asp.net engine and
the output will be sent to the browser. ASP.Net 2.0 answered this issue by introducing a new feature to comment the
server side elements.This server side comments will prevent the asp.net to parse and execute the
contents.
<%-- Server side comments
--%>
For example, the below commented
statements will not be parsed by ASP.Net engine during the page processing.
<%--
<asp:TextBox CssClass="stocktextfont"
ID="txtChildNumber" runat="server" ReadOnly="True"
BackColor="#FFE0C0"
Width="232px"
TabIndex="4"></asp:TextBox>
--%>
The output html will not have the
markup generated for the above textbox.
Refreshing ASPX Page Automatically
from Server side Meta tags in ASP.Net 2.0
With the introduction of ASP.Net 2.0,
we can set meta tags dynamically from codebehind class using HtmlMeta class. To
refresh our aspx page from the codebehind class we can use the following
code,
HtmlMeta meta = new HtmlMeta();
HtmlHead head =
(HtmlHead)Page.Header;
meta.HttpEquiv = "refresh";
meta.Content = "5";
head.Controls.Add(meta);
Default Button in ASP.Net
2.0
ASP.Net 2.0 has a property called
default button in <form> tag and in Panel control. This enables the user
to submit the form when the user hits enter.
<form id="form1" runat="server"
defaultbutton="btnSave">
and
<asp:Panel ID="Panel1"
DefaultButton="btnSave" runat="server"></asp:Panel>
Setting this attribute in form tag
makes the default button globally to that page and setting the default button
attribute in Panel controls submits page when the user hits enter key inside the
panel control.
|