AJAX, Intercept Submit before it happens

L

Lit

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
 
L

Larry Bud

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.
 
L

Lit

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.
 
M

Mark Rae [MVP]

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');");
 
L

Lit

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
 
M

Mark Rae [MVP]

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?

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

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top