Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a login page and a home page.I want to fire a function on home page after this page has been loaded successfully.
If I keep the function on pageload or other page related event of home page,the function is firing when the page is redirecting from login to home page.

But I want a different but common thing----------------
User clicks on login button->homepage comes up(with no function execution)->loading animation will show with backgroung disable->in this time my function should execute->after function execution loading message will disappear.

I hope I can make you understand.

Please help how to do this.

I know this can not be done with page related event.
Posted
Comments
Kumar Pankaj Verma 7-Jan-15 12:31pm    
1. Use a div tab on homepage with transparency and higher zindex to block user action on home page while loading.
2. call a javascript function which will hide this div after body tag in page. OR you can use jquery $(document).ready method to hide that div.

1 solution

Not that this issue it totally related to the client side and the time when all the content is completely downloaded, so it does not really matter what it was on the server side, ASP.NET, plain static HTML file, or anything else.

One of the ways to make sure that some processing is done when the page is completely loaded is using jQuery, with its standard usage style pretty much based on that: http://learn.jquery.com/about-jquery/how-jquery-works[^].

Pay attention for the top-level script starting with handling $(document).ready.

—SA
 
Share this answer
 
v2
Comments
Kornfeld Eliyahu Peter 7-Jan-15 12:47pm    
I didn't know you can set a function on fire using jQuery :-)...
+5
Sergey Alexandrovich Kryukov 7-Jan-15 12:53pm    
Thank you, Peter.
Actually, the whole jQuery stile is based on such thing.
—SA
souvikcode 10-Jan-15 10:45am    
But where to write server side code in this case?In which event?I think I have to write the server side function in webmethod and have to call by json on document.ready method.I think this should be solution.
Sergey Alexandrovich Kryukov 10-Jan-15 12:44pm    
It's up to you where you post to server side. I don't know what do you mean by this "server-side function" though, please clarify. If you still mean a Javascript function written in code behind, you should understand that this is still a client-side function (generated via RegisterScript). And if this is really a server-side function, it is never called by client-side function. Consider two facts: 1) handling of the even when the document is ready is done on client part and only client part, Javascript; 2) client-part functions never ever call server-side functions and server-side functions never call client-side functions. You can use Ajax; the most convenient way would be using jQuery .Ajax().
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900