asp.net page's preinit event

試著忘記壹切 提交于 2019-12-10 17:49:38

问题


I am new to asp.net. I have an aspx page and i have to write some code in its PreInit event. From where i find PreInit event on the page. As we double click on button to get button click event(or selecting button and select event from property pane) Plz reply me ASAP.


回答1:


Man, why do you need the mouse?

If you need to write some code into PreInit just write the code:

protected virtual void OnPreInit(EventArgs e)
{
   base.OnPreInit(e);
   //your code
}

or in class constructor add a event handler for it:

...
PreInit += new EventHandler(SomeMethodName)
...

and define the event handler method

private void SomeMethodName(object sender, EventArgs e)
{
   //your code
}

And by the way, check a .Net Framework book and a Visual Studio manual.




回答2:


You need to do some reading:

http://msdn.microsoft.com/en-us/library/ms178472.aspx#lifecycle_events



来源:https://stackoverflow.com/questions/6042653/asp-net-pages-preinit-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!