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?
Asked
Active
Viewed 2,242 times
1
-
1What do you mean by *loads completely*? Loads where? On the client browser? – Darin Dimitrov Feb 18 '11 at 08:59
-
I mean After Page is fully displayed on the client browser .. – Ameno Feb 18 '11 at 09:43
4 Answers
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
-
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:34
-
1@Ameno: I would take a look at `jQuery` and use the `$(document).ready(function())`. – Neil Knight Feb 18 '11 at 09:43
-
-
@Ameno: Yep! http://www.dotnetspark.com/kb/1453-call-server-side-function-using-jquery-asp-net.aspx – Neil Knight Feb 18 '11 at 10:07
-
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
-
-
-
Actually I need to trigger the C# function when the page is fully displayed – Ameno Feb 18 '11 at 10:13