#Region " Imports " Imports System Imports System.Configuration Imports System.Data Imports System.Globalization #End Region Public Class PopupCalendar #Region " Instance Fields +" ' Get the short date pattern for the culture Shared FormatString As String = DateTimeFormatInfo.CurrentInfo.ShortDatePattern.ToString ' Define character array to trim from language strings Shared TrimChars As Char() = {","c, " "c} Shared MonthNameString As String = MonthName() Shared DayNameString As String = DayName() #End Region #Region " Public Methods " Public Shared Function Invoke(ByVal Field As System.Web.UI.WebControls.TextBox) As String Return "javascript:popupCal('Cal','" & Field.ClientID & "','" & FormatString & "','" & MonthNameString & "','" & DayNameString & "');" End Function #End Region #Region " Private Methods " Shared Function MonthName() As String ' Get culture array of month names and convert to ' string for passing to the popup calendar Dim Month As String = String.Empty Dim Result As String = String.Empty For Each Month In DateTimeFormatInfo.CurrentInfo.MonthNames Result += Month & "," Next Return Result.TrimEnd(TrimChars) End Function Shared Function DayName() As String ' Get culture array of day names and convert to string for ' passing to the popup calendar Dim Day As String = String.Empty Dim Result As String = String.Empty For Each Day In DateTimeFormatInfo.CurrentInfo.DayNames Result += Day.Substring(0, 3) & "," Next Return Result.TrimEnd(TrimChars) End Function #End Region End Class ' ******************************** USAGE EXAMPLE ******************************** ' '
' ' ' ' ' ' 'Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' If Not IsPostBack Then ' DateHyperlink.NavigateUrl = PopupCalendar.Invoke(DateTextbox) ' End If 'End Sub