Display calendar control in your asp.net web page using VB.NET. Below is the code example
Design:
<%@ Page CodeBehind="calender.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="Internet.calender" %>
Calendar
.VB File:
Public Class calendar
Inherits System.Web.UI.Page
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents butClear As System.Web.UI.WebControls.Button
Protected WithEvents Literal1 As System.Web.UI.WebControls.Literal
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Public Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
If e.Day.Date = DateTime.Now.ToString("d") Then
e.Cell.BackColor = System.Drawing.Color.LightGray
End If
End Sub
Public Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim strsdate As String
Dim objGetDate As New Utils()
strsdate = objGetDate.FormatDate(Calendar1.SelectedDate)
Dim strjscript As String = "" 'Don't Ask, Tool Bug
Literal1.Text = strjscript 'Set the literal control's text to the JScript code
objGetDate = Nothing
End Sub
Private Sub butClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butClear.Click
Dim strjscript As String = "" 'Don't Ask, Tool Bug
Literal1.Text = strjscript 'Set the literal control's text to the JScript code
End Sub
End Class