SanamShaikh
SanamShaikh

Reputation: 1809

Usercontrol pageload events fires AFTER ASPX pageload event

  1. I have a user control (WODetails.ascx) that gets WOCode and fill some fields related to work order.
  2. I have a ASPX page that contains a grid and above user control once i click on grid control (ROWCommand Event fires)

I want to call pageload event once rowcommand event fires, beacuse rowcommand retruns WOCOde and my usercontrol should fill fields accordingly. But problem is usercontrol pageload events fires after ASPX pageload event fires

Upvotes: 1

Views: 1791

Answers (1)

Mateus Schneiders
Mateus Schneiders

Reputation: 4903

The Page_Load is an event called by the .NET framework, it is intended to notify the Controls of the stage of the page life cycle. It is not meant for this kind of communication.

If you want to communicate with the UserControl, why not writing a custom method on the UserControl?

public class WODetails : UserControl
{
    ...

    public void DoMyStuff(object WOCOde)
    {
        ...
    }

    ...
}

And on the ASPX, you just call it when you need:

void grdDummy_RowCommand(object sender, GridViewCommandEventArgs e)
{
    object WOCOde = GetWOCode(e);
    WODetails.DoMyStuff(WOCOde);
}

Upvotes: 2

Related Questions