开发者

Why is it possible to set the properties of server controls as early as in the Page_PreInit handler?

An aspx page's Page_PreInit event happens before an开发者_JS百科 component server control's (e.g. a TextBox) Init event. However it is possible to set a TextBox's Text property in Page_PreInit. I suppose this means the TextBox's Text is set before the TextBox is even initiated. How is that possible?


I suppose you need to tell why you want it, what is the scenerio in which you wish to use it since at least I never used textbox's text property in preinit. But you may put a text box to the page and in the codebehind you may write:

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
    TextBox1.Text = "test"
End Sub


At: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox_events.aspx. it says textbox init event occurs when the control is initialized not before it. And it also says that init is the first step of it's lifecycle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜