Initiate PostBack From Client-side Script

Discussion in 'ASP .Net' started by Jordan, Jul 23, 2004.

  1. Jordan

    Jordan Guest

    I'm trying to initiate Postback from client-side script, and here's what I
    have that doesn't work: I have an <asp:Button> on the same page named
    btnSave that the user can click (its functionality works fine). I want to
    call the button's server-side functionality from the client-side script (in
    response to things happening in the client other than the user clicking on
    the save button).

    function DoSomethingInClient()
    {
    Do Some Stuff Here
    __doPostBack('btnSaveClick','');
    }

    What could be wrong with this?

    Thanks.
     
    Jordan, Jul 23, 2004
    #1
    1. Advertising

  2. Jordan

    Dale Guest

    Are you sure you have the method __doPostBack() in your client? If you
    don't have any controls set for postback, it can happen that the code is not
    generated to the client.

    In the Framework documentation or MSDN, search for the article titled
    "Generating Client-Side Script for Postback."

    It talks about the GetPostBackEventReference method. This method will
    return method call string so you can use it in programatically generated
    client scripts but the most important thing it will do for you is that, if
    it doesn't already exist by other means, it will generate the __doPostBack
    method itself so that you can call it.

    Dale Preston
    MCAD, MCSE, MCDBA

    "Jordan" <> wrote in message
    news:...
    > I'm trying to initiate Postback from client-side script, and here's what I
    > have that doesn't work: I have an <asp:Button> on the same page named
    > btnSave that the user can click (its functionality works fine). I want to
    > call the button's server-side functionality from the client-side script

    (in
    > response to things happening in the client other than the user clicking on
    > the save button).
    >
    > function DoSomethingInClient()
    > {
    > Do Some Stuff Here
    > __doPostBack('btnSaveClick','');
    > }
    >
    > What could be wrong with this?
    >
    > Thanks.
    >
    >
     
    Dale, Jul 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Magnus Blomberg
    Replies:
    3
    Views:
    735
    Magnus Blomberg
    Apr 14, 2005
  2. Jeff Jarrell
    Replies:
    0
    Views:
    551
    Jeff Jarrell
    Oct 26, 2005
  3. =?Utf-8?B?Y2lu?=

    How to initiate a postback in a function?

    =?Utf-8?B?Y2lu?=, Nov 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,321
    Wouter van Vugt
    Nov 24, 2005
  4. sonic
    Replies:
    0
    Views:
    527
    sonic
    Jun 26, 2006
  5. Boss302
    Replies:
    0
    Views:
    1,086
    Boss302
    Nov 21, 2006
Loading...

Share This Page