Using the same <% %> code blocks developer can modify the HTML output dynamically likewise in simple asp pages. The below example demonstrates how <% %> blocks can be used to modify text output of an HTML block increasing the font size each time:
<html> <head> <title>ASP.Net Code Page</title> </head> <body> <% for i as integer= 1 to 6 %> <font size="<% =i %>">Hello</font><br/> <% next %> </body> </html> Save above code as example3.aspx and check the output.
VB CODE FOR VB NET DATE TIME FUNCTION <%@ Page Language="VB" %> <html> <body> <h1>VB.Net Date Time Function</h1> <br/> <h2>The date and time is <% =DateTime.Now( ) %>.</h2> </body> </html> C# CODE FOR C# NET DATE TIME FUNCTION <%@ Page Language="C#" %> <html> <body> <h1>C#.Net Date Time Function</h1> <br/> <h2>The date and time is <% =DateTime.Now.ToString( ) %>.</h2> </body> </html> You can copy above asp.net code to get current server date time. DateTime.Now( ) function runs on server side and returns the server current date and time.
Take care of including the page headers
For VB page header use: <%@ Page Language="VB" %>
For C# page header use: <%@ Page Language="C#" %>
You can build your dynamic asp .net web site by using Visual Web Developer Express Edition. Click here to learn how to install asp .net on your PC.
Be the first to rate this post
Tags: adding code to a page, date time function, asp .net program
8/23/2008 8:45:47 PM