Forum Moderators: open

Message Too Old, No Replies

How to emulate life cycle of dynamically created page?

How to emulate life cycle of dynamically created page?

         

Nagval

11:03 am on Jul 11, 2006 (gmt 0)

10+ Year Member



Hello All!
I'm sorry for my english.

How to emulate life cycle of dynamically created page?

User’s request handles in Global.asax in Application_BeginRequest. Depending on URL the page is constructing dynamically and directed back to user.

System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter tw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

Page p = new Page();
System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
System.Web.UI.WebControls.Button btn = new System.Web.UI.WebControls.Button();
System.Web.UI.WebControls.TextBox text = new System.Web.UI.WebControls.TextBox();
text.TextChanged += new EventHandler(text_TextChanged); text.ID = "test1";

btn.Text = "Return";
form.Controls.Add(btn);
form.Controls.Add(text);
p.Controls.Add(form);

p.EnableViewState = true;
p.RenderControl(hw);

Response.Write(sb.ToString());
Response.End();

How to handle post back of this page (emulate full life cycle) and control events like

text.TextChanged += new EventHandler(text_TextChanged);

Please advise.

wardbekker

12:56 pm on Jul 11, 2006 (gmt 0)

10+ Year Member



Hi Nagval,

Instead of global.asax handeling the dynamic creation of a page, you might want to redirect (or Server.Transfer) to a real aspx (Page1), and let it handle the dynamic creation of controls. That way Page1 also receives the events.

Good luck,

Ward

Nagval

3:13 pm on Jul 11, 2006 (gmt 0)

10+ Year Member



Thanks for respond.

Is there any ability do not use real aspx file (Page1). Like it realized in SPS?

wardbekker

6:51 am on Jul 13, 2006 (gmt 0)

10+ Year Member



Nagval,

Probably yes, but you might need to jump through hoops to get it working correctly like that.

Nagval

8:06 am on Jul 20, 2006 (gmt 0)

10+ Year Member



How can I do that? Have you any simples? link to articles?