Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can't access control created in Calendar 'DayRender' event

Reply
Thread Tools

Can't access control created in Calendar 'DayRender' event

 
 
champagne.supernova1974@googlemail.com
Guest
Posts: n/a
 
      11-20-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I access a calendar control inside a detailsview control? Tamer Ibrahim ASP .Net Datagrid Control 3 01-30-2007 11:02 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
Calendar Control - Programatically set the calendar to a date range Shevek ASP .Net 3 06-23-2004 01:41 PM
Calendar Control - Programatically set the calendar to a date range Shevek ASP .Net Web Controls 0 06-23-2004 12:06 PM
Passing event from dynamically created element and event handler? Adi Javascript 2 02-23-2004 02:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57