Call server side events and functions from Javascript

Discussion in 'ASP' started by naimish, Sep 1, 2009.

  1. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth

    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();
    }
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    This works only for ASP.net, if there any way to this in other languages like PHP?
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  4. djbrown

    djbrown New Member

    Joined:
    Oct 22, 2009
    Messages:
    16
    Likes Received:
    1
    Trophy Points:
    0
    This works only for ASP.net?
     
  5. technica

    technica New Member

    Joined:
    Dec 15, 2007
    Messages:
    107
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.technicaltalk.net
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice