1

I need to trigger a C# code behind function right after an ASP.NET page is completely displayed.
Is there an event to program?
If not, do how to do it?

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Ameno
  • 11
  • 4

4 Answers4

2

What you might want to try is Page Methods/WebMethods. Take a look at the tutorial on singingeels.com, basically it boils down to:

  • Respond to the Sys.Application.load event to trigger a call back to the server to a page method
  • Create a page method that contains the logic you wish to execute in response to the call
  • Respond to the result sent back from the page method, as appropriate in an OnSucceeded/OnFailed event.
Rob
  • 45,296
  • 24
  • 122
  • 150
0

You can use the Page_PreRender event. This is called just before the Page is displayed.

Neil Knight
  • 47,437
  • 25
  • 129
  • 188
0

Create a 'New Web Site' - the default website template comes with an example; the _Default class has the following:

protected void Page_Load(object sender, EventArgs e)
{

}

There are other events in the ASP.NET Page Life cycle which may be of interest to you. Hope this helps.

Alex
  • 3,644
  • 2
  • 19
  • 27
  • Thank you for your answer but I need to fire the function right after the page is fully displayed . Any Idea? – Ameno Feb 18 '11 at 09:32
0

Try using this.

protected override void OnLoad(EventArgs e)
{
   base.OnLoad(e);
   // your code!
}
Nirmal
  • 1,223
  • 18
  • 32