Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page event is not getting fired at all

Tags:

c#

asp.net

I am trying to use the Page_LoadComplete in my user control myusercontrol.ascx.cs but its not getting fired up, I added a break point and nothing, it is possible that the user control does not support this event? and if thats the case what can I use instead?

like image 699
user710502 Avatar asked Mar 07 '12 20:03

user710502


2 Answers

LoadComplete is not automatically wired up.. You'll have to do that yourself.

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.LoadComplete += new EventHandler(Page_LoadComplete);
    }

    void Page_LoadComplete(object sender, EventArgs e)
    {
        //Do your deed
    }

Reference: http://connect.microsoft.com/VisualStudio/feedback/details/103322/page-loadcomplete-doesnt-fire-in-custom-controls

like image 124
Khan Avatar answered Oct 05 '22 06:10

Khan


The LoadComplete event only happens on the Page. For a control, if you want to do something after the other controls' Load events have fired, about the closest you'll get is PreRender.

Alternatively, you could attach to the Page's LoadComplete event in your control's init stuff. But AFAIK it won't happen automatically.

like image 41
cHao Avatar answered Oct 05 '22 06:10

cHao