Pre_Init

M

Mike

protected void Page_PreInit(object sender, EventArgs e)

{

TextBox1.Text = TextBox1.GetType().ToString();

}

In the Pre_Init event of the page, I can set the value of say a TextBox's
Text property, but the TextBox isn't created until the Init event. Also I
noticed while debugging that 'The name 'x' does not exist in the current
context' appears if I set a breakpoint just after setting the TextBox.Text
value.

If I try to reference a control that doesn't exist after the Init event, I
get a runtime error. Why don't I get one in the Pre_init example above?

Mike
 
B

bruce barker

the controls defined on the aspx page are created at
FrameworkInitialize, which is well before PreInit.

-- bruce (sqlwork.com)
 
M

Mike

Do you know, in all the Page Life Cycle articles I have read, I've never
seen FrameworkInitialize mentioned.

Thank you.
 

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

Top