Dynamically created controls not accessible on postback

  • Thread starter Thread starter Tim Greenwood
  • Start date Start date
T

Tim Greenwood

I am using the calendar control provided for ASP.NET. I am adding a
checkbox during the DayRender event as follows:


private void calMonth_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)

{

System.Web.UI.WebControls.CheckBox cb = new
System.Web.UI.WebControls.CheckBox();

cb.EnableViewState = true;
cb.ID="p" + e.Day.Date.ToShortDateString().Replace("/","_");
cb.Text = "Play";

e.Cell.Controls.Add(cb);
}


I have a command button for submitting the changes but cannot figure out how
to access the dynamically created checkboxes on postback. The WebCalendar
does not
expose the table object it creates so how would I be able to access the
values of these checkboxes??

I've kind of reached my end here...any help would be most appreciated..
 
Hi,

with this type of approach, it could happen only via Request.Form collection
manually. With this type of approach as I have here (it just uses control
instances which are there by the time Page_load runs)
http://blogs.aspadvice.com/joteke/archive/2004/08/05/1444.aspx

But you don't have instances in your case, as that code runs in render
phase.And you probably want the info in Page_Load or event handler at the
latest...
 
Back
Top