Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Way to call code-behind event

Hi,
I want to call one code-behind event within one javascript event. Can you please show with one example to this?
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

What method you would like to call and why? Whatever you do in server side try to perform in client side if possible. Otherwise please try below solution.

 You can't call the asp.net life cycle methods such as page_load. Instead, you could write the server side method as webservice and call it in either javascript or ajax. Following links could be helpful.

http://aspsnippets.com/Articles/Calling-server-side-methods-using-JavaScript-and-JQuery-in-ASP.Net.aspx

http://www.morgantechspace.com/2014/01/Call-Server-Side-function-from-JavaScript-in-ASP-NET.html

HTH.
Avatar of Peter Chan

ASKER

Many thanks Easwaran.

Is it possible to call this
            ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);

Open in new window


within server-side method?
I have tried it and have got that it is no possible to execute ClientScript within server-side method. How to resolve this?
ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I really don't have time to confirm if this is surely the answer or not.