Академический Документы
Профессиональный Документы
Культура Документы
1. Take a moment to change the Literal Web control's Text property to Hello,
World!.
2. Now that we've added this Literal Web control and set its Text property, let's
view this ASP.NET web page through a browser. Go to the Debug menu and
choose Start Without Debugging.
1. Let's create an ASP.NET web page that uses a Label Web control to display the
current date and time. Start by creating a new ASP.NET web page named
LiteralTime.aspx, and then drag and drop a Literal Web control onto the
designer. We don't need to set the Text property through the Properties window
because we will be setting this property programmatically. We should, however,
rename the Literal Web control's ID property from the ambiguous Label1 to
something more descriptive, such as currentTime.
2. After we've added the Literal Web control and set its ID property to currentTime,
we're ready to add the needed source code. Start by creating an event handler for
the page's Load event by double-clicking in the Design view region or going to
the source code portion and selecting (Page Events) from the left drop-down list
and Load from the right. For this ASP.NET web page, we want to have the Literal
Web control's Text property set to the current date and time whenever the page is
visited. Therefore, we will do so in the Page_Load event handler.
Enter the following code into your Page_Load event handler:
currentTime.Text = DateTime.Now
3. After you have entered this source code content, save the ASP.NET web page and
run it.