Executing javascript on post

S

Scott

I have an asp.net page that performs a function for a user that can
take up to 30 seconds. So, I have a javascript function that shows an
animation to let the user know something is going on. I have tied
this animation to the single button on the page with the following
piece of code:

btn_rc.Attributes.Add("onClick", "status_change();")

This works great. When I click the button, I get the animation, and
when the page finishes the animation ends.

Now, since this is the only button on the page, I want to let the user
use the enter key to submit the form as well. So, with another piece
of code, I have successfully accomplished that:

Page.RegisterHiddenField("__EVENTTARGET", "btn_rc")

Now for the problem:

If the user hits the enter button to submit the form, it works but
does not display the javascript animation. How can I get the same
javascript animation to display if the enter key is hit vs. clicking
my submit button?

Thanks.
Scott
 
V

Victor Garcia Aprea [MVP]

Hi Scott,

You should be able to attach to the client-side form's onsubmit event to run
you javascript function just before the form gets submited.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top