Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/articles/asp-tutorials/)
-   -   Call server side events and functions from Javascript (http://www.go4expert.com/articles/server-events-functions-javascript-t19251/)

naimish 1Sep2009 08:44

Call server side events and functions from Javascript
 

Introduction



To call server side events and functions from client side javascript function in asp.net.

Suppose we want to perform both client side and server side activities for an event,we can use this logic

Background



Three are 2 ways to acheive this functionality.

one using __dopostback() and another using form.submit(). Say you are having a client side javascript function named clientfunction. From clientfunction if u want to call any serverside function or serverside event(eg: dropdown selected index change) say server function and serverdropdown.

The code




Code:

function clientfunction
{
        //do the client side validations here
        //
        //now call the server side dropdown event explicitly
        __doPostBack('cboserverdropdown','');
}

Code:

function clientfunction
{
        //do the client side validations here
        //
        //or just give below code
        form.submit();
}


pradeep 2Sep2009 13:35

Re: Call server side events and functions from Javascript
 
This works only for ASP.net, if there any way to this in other languages like PHP?

shabbir 3Oct2009 17:07

Re: Call server side events and functions from Javascript
 
Nomination for Article of the month - Sep 2009 Started. Nominate this article.

djbrown 22Oct2009 14:41

Re: Call server side events and functions from Javascript
 
This works only for ASP.net?

technica 21Apr2010 11:57

Re: Call server side events and functions from Javascript
 
I am looking for the way to do this in classic asp 3.0 language. If you know how to do it then please post article for that too. By the way this article is good.


All times are GMT +5.5. The time now is 05:44.