AJAX, Intercept Submit before it happens

Discussion in 'ASP .Net' started by Lit, Jul 30, 2007.

  1. Lit

    Lit Guest

    Hi,

    I have an update panel with a Submit Button. ( AJAXified )

    Is there a way, good way, of Intercepting a submit before it happens?

    I would like to do something in JavaScript before proceeding with the submit
    process.

    How to Inject such JavaScript from Code Behind?

    Thank You,

    Lit
    Lit, Jul 30, 2007
    #1
    1. Advertising

  2. Lit

    Larry Bud Guest

    On Jul 30, 12:44 pm, "Lit" <> wrote:
    > Hi,
    >
    > I have an update panel with a Submit Button. ( AJAXified )
    >
    > Is there a way, good way, of Intercepting a submit before it happens?
    >
    > I would like to do something in JavaScript before proceeding with the submit
    > process.
    >
    > How to Inject such JavaScript from Code Behind?
    >
    > Thank You,
    >
    > Lit


    OnClientClick for the button. If you return TRUE, the action will
    occur.
    Larry Bud, Jul 30, 2007
    #2
    1. Advertising

  3. Lit

    Lit Guest

    Larry,

    Excellent ( For the Submit Button ), What about something like a ListBox
    Control that does not have OnClientClick that I can see.

    Thanks for your quick reply.

    Lit.

    "Larry Bud" <> wrote in message
    news:...
    > On Jul 30, 12:44 pm, "Lit" <> wrote:
    >> Hi,
    >>
    >> I have an update panel with a Submit Button. ( AJAXified )
    >>
    >> Is there a way, good way, of Intercepting a submit before it happens?
    >>
    >> I would like to do something in JavaScript before proceeding with the
    >> submit
    >> process.
    >>
    >> How to Inject such JavaScript from Code Behind?
    >>
    >> Thank You,
    >>
    >> Lit

    >
    > OnClientClick for the button. If you return TRUE, the action will
    > occur.
    >
    Lit, Jul 30, 2007
    #3
  4. "Lit" <> wrote in message
    news:...

    > Excellent ( For the Submit Button ), What about something like a ListBox
    > Control that does not have OnClientClick that I can see.


    MyListBox.Attributes.Add("onclick", "alert('Clicked');");


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 30, 2007
    #4
  5. Lit

    Lit Guest

    Mark,

    If I already have an onclick - server event, how do I Intercept before I
    post back?

    or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is it
    called something else for the ListBox on the client side?

    Does the Client script event handler get executed then the server event
    handler after the post?

    Thank much for your time

    Lit



    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Lit" <> wrote in message
    > news:...
    >
    >> Excellent ( For the Submit Button ), What about something like a ListBox
    >> Control that does not have OnClientClick that I can see.

    >
    > MyListBox.Attributes.Add("onclick", "alert('Clicked');");
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Lit, Jul 30, 2007
    #5
  6. "Lit" <> wrote in message
    news:...

    > If I already have an onclick - server event, how do I Intercept before I
    > post back?


    Larry's already answered that... You add a client-side onclick event and
    capture the return value - if it's false, the postback won't happen...

    > or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is
    > it called something else for the ListBox on the client side?


    An <asp:ListBox> webcontrol gets rendered as an HTML <select> - you need the
    onchange event...

    > Does the Client script event handler get executed then the server event
    > handler after the post?


    Yes, unless the client-side event returns false...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 30, 2007
    #6
  7. Lit

    bruce barker Guest

    see RegisterOnSubmitStatement

    -- bruce (sqlwork.com)

    Lit wrote:
    > Hi,
    >
    > I have an update panel with a Submit Button. ( AJAXified )
    >
    > Is there a way, good way, of Intercepting a submit before it happens?
    >
    > I would like to do something in JavaScript before proceeding with the submit
    > process.
    >
    > How to Inject such JavaScript from Code Behind?
    >
    > Thank You,
    >
    > Lit
    >
    >
    >
    bruce barker, Jul 30, 2007
    #7
  8. Lit

    Lit Guest

    Mark,

    "onchange" is what I was looking for.

    Thanks for the help

    Lit.


    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "Lit" <> wrote in message
    > news:...
    >
    >> If I already have an onclick - server event, how do I Intercept before I
    >> post back?

    >
    > Larry's already answered that... You add a client-side onclick event and
    > capture the return value - if it's false, the postback won't happen...
    >
    >> or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is
    >> it called something else for the ListBox on the client side?

    >
    > An <asp:ListBox> webcontrol gets rendered as an HTML <select> - you need
    > the onchange event...
    >
    >> Does the Client script event handler get executed then the server event
    >> handler after the post?

    >
    > Yes, unless the client-side event returns false...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Lit, Jul 30, 2007
    #8
    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. Adam Smith

    Intercept html before rendering

    Adam Smith, May 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    606
    Adam Smith
    May 27, 2004
  2. =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?=

    Can you intercept the url request before a 404 error occurs?

    =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?=, Jul 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    629
    Scott Allen
    Jul 14, 2004
  3. =?Utf-8?B?cnBhbGU=?=

    httphandler to intercept pages before sent to user

    =?Utf-8?B?cnBhbGU=?=, Dec 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    559
    Steven Cheng[MSFT]
    Dec 16, 2004
  4. LP
    Replies:
    5
    Views:
    610
    Robbe Morris [C# MVP]
    Feb 19, 2005
  5. NM
    Replies:
    6
    Views:
    449
    Default User
    Sep 20, 2006
Loading...

Share This Page