Although Web programming software such as Dreamweaver and Microsoft Expressions can create ASP.NET pages, using Microsoft’s free Visual Web Developer 2008 Express Edition (VWD) simplifies adding ASP.NET controls, particularly the AJAX additions. Download this and the ASP.NET framework from the link in Additional Resources if you do not already have the software.
Start this example by opening VWD and creating a new ASP.NET page. Click on “File,” “New File” and select the “Web Form” template. In the list of templates, you will also see an “AJAX Web Form,” which simplifies using AJAX but this introduction uses a longer route to demonstrate the difference between full and partial postback. Name the form “UpdateControlDemo.” VWD will create two files. One is the aspx file with this name and the second is the Visual Basic code file, which will be name “UpdateControlDemo.aspx.vb.” Both are shown in separate tabs in VWD.
In the Design view, add a label control from the Toolbox on the left. Empty the Text property in the Properties panel on the right and change the ID to “Current Time.” Add a Button control from the Toolbox and change the button ID to “btnFullPB” and the Text to “Full Postback.” Click on the UpdateControlDemo.aspx.vb tab, which should open in Source view. Enter the follow lines of code on the first empty line after the line beginning “Inherits System.Web.UI.Page”:
Protected Sub Page_Load(ByVal sender as Object, ByVal e as System.EventArgs) Handles Me.Load
CurrentTime.Text = DateTime.Now
End Sub
This sets up a display of the current time when the page loads. Now check the page in “View in Browser” or load it on a live Web page on your site. When you click on the “Full Postback” button, the current date and time should display. Each time you click on this, it will update.