user710502
user710502

Reputation: 11471

Page event is not getting fired at all

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?

Upvotes: 7

Views: 7277

Answers (2)

cHao
cHao

Reputation: 86506

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.

Upvotes: 12

Khan
Khan

Reputation: 18142

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

Upvotes: 27

Related Questions