Tuesday, June 18, 2013

Embedded Code Blocks

An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class.

<%@ Page Language="C#" %>
<html>
<body>
    <form id="form1" runat="server">
    <% for(int i = 0; i < 6; i++) %>
       <% { Response.Write("<br>" + i.ToString()); }%>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<script runat=server>
protected String GetTime()
{
    return DateTime.Now.ToString("t");
}
</script>
<html>
<body>
    <form id="form1" runat="server">
       Current server time is <% =GetTime()%>.
    </form>
</body>
</html>

No comments:

Post a Comment