I have created a calendar control so I can reuse it on various web forms. I can select a date from the calendar at run time and it appears on my web form. However, what I cannot figure out is how to capture that date in my current form. The text box in my control is txtCalendarDate, however my web form does not see this text box. It's simply a control. The code for my calendar control is:
Public MustInherit Class CalendarControl
Inherits System.Web.UI.UserControl
Protected WithEvents txtCalendarDate As System.Web.UI.WebControls.TextBox
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
txtCalendarDate.Text = Calendar1.SelectedDate.ToShortDateString()
Dim div As System.Web.UI.Control = Page.FindControl("divCalendar")
If TypeOf div Is HtmlGenericControl Then
CType(div, HtmlGenericControl).Style.Add("display", "none")
End If
End Sub
End Class
In other words, how do I pass this txtCalendarDate to the form I have the control on?
Public MustInherit Class CalendarControl
Inherits System.Web.UI.UserControl
Protected WithEvents txtCalendarDate As System.Web.UI.WebControls.TextBox
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
txtCalendarDate.Text = Calendar1.SelectedDate.ToShortDateString()
Dim div As System.Web.UI.Control = Page.FindControl("divCalendar")
If TypeOf div Is HtmlGenericControl Then
CType(div, HtmlGenericControl).Style.Add("display", "none")
End If
End Sub
End Class
In other words, how do I pass this txtCalendarDate to the form I have the control on?