C
champagne.supernova1974
Hi
Can anyone help with a quick question?
I am adding a textbox into each "day" cell of a calendar control, by
using the following code in the DayRender event:
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DayRenderEventArgs) Handles
Calendar1.DayRender
If Not e.Day.IsOtherMonth Then
Dim txtDayCell As New TextBox
txtDayCell.ID = "txtMonth" & e.Day.DayNumberText
e.Cell.Controls.Add(txtDayCell)
End If
End Sub
My problem is that when I then try to access the textbox value in
PageLoad, I get an 'Object reference not set to an instance of an
object' error at the line I've highlighted in my 'test' code below
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim txtMonth1 As New TextBox
txtMonth1 = Page.FindControl("txtMonth1")
Dim Button1 As New Button
Button1 = Page.FindControl("Button1")
If Me.IsPostBack Then
Button1.Text = txtMonth1.Text **** Error is thrown here
*****
End If
End Sub
I suspect I've not quite got my timing right with the page lifecycle
side of this - could anyone suggest how I can access the textboxes in
the calendar cells. from a postback?
Many thanks for your help guys.
Mark
Can anyone help with a quick question?
I am adding a textbox into each "day" cell of a calendar control, by
using the following code in the DayRender event:
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DayRenderEventArgs) Handles
Calendar1.DayRender
If Not e.Day.IsOtherMonth Then
Dim txtDayCell As New TextBox
txtDayCell.ID = "txtMonth" & e.Day.DayNumberText
e.Cell.Controls.Add(txtDayCell)
End If
End Sub
My problem is that when I then try to access the textbox value in
PageLoad, I get an 'Object reference not set to an instance of an
object' error at the line I've highlighted in my 'test' code below
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim txtMonth1 As New TextBox
txtMonth1 = Page.FindControl("txtMonth1")
Dim Button1 As New Button
Button1 = Page.FindControl("Button1")
If Me.IsPostBack Then
Button1.Text = txtMonth1.Text **** Error is thrown here
*****
End If
End Sub
I suspect I've not quite got my timing right with the page lifecycle
side of this - could anyone suggest how I can access the textboxes in
the calendar cells. from a postback?
Many thanks for your help guys.
Mark