This document contains code for three ASP.NET webform programs. The first program uses a Calendar control and handles its VisibleMonthChanged event to display whether the month was changed forward or backward. The second program demonstrates validation controls like RequiredFieldValidator and RangeValidator. The third program uses a master page to create a common layout for pages with a menu control populated from a sitemap file.
2. </div>
</form>
</body>
</html>
Webform1.aspx.vb
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
End Sub
Sub MonthChange(sender As Object, e As MonthChangedEventArgs)
If e.NewDate.Month > e.PreviousDate.Month Then
Message.Text = "You moved forward one month."
Else
Message.Text = "You moved backwards one month."
End If
End Sub
End Class
3.
4. Program 02:
Using the Validation Controls
Webform2.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb"
Inherits="WebApplication2.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><h1>Using the Validation Control</h1></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"
Text="RequiredField Validator Control Example" Font-Bold="True"
Font-Size="Medium" Font-Underline="True"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Small"
Text="User name:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="22px"
Width="175px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="User name can not be
empty"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Small"
Text="Password:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Height="22px" TextMode="Password"
Width="175px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Password can not be
empty"></asp:RequiredFieldValidator>
<br />
<br />
Age: <asp:TextBox
ID="TextBox3" runat="server" ViewStateMode="Disabled" Width="175px"></asp:TextBox>
<asp:RangeValidator runat="server" id="rngDate" controltovalidate="TextBox3"
minimumvalue="20" maximumvalue="30" errormessage="Please enter the age between 20 to 30"
/>
<br />
<asp:Button ID="Button1" runat="server" BackColor="Black" Font-Bold="True"
Font-Size="Medium" ForeColor="White" Text="Submit" />