Dynamically created controls not accessible on postback

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..
 
T

Teemu Keiski

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top