Executing javascript on post

  • Thread starter Thread starter Scott
  • Start date Start date
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
 
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
 
Back
Top