.Net 2.0: Button, OnClientClick, and Click EventHandler not all working nicely...

  • Thread starter Dan Christensen
  • Start date
D

Dan Christensen

Hi, I've got my own validation javascript for a form, which works
great.

I add it into the processing loop with
btn.OnClientClick = "if (!form_onsubmit(this)) return false;";

form_onsubmit is my custom validation function which disables the
button, validates my fields, and returns true if valid, false
otherwise.

The if() wrapping trick was found on a blog, and was necessary because
returning true simply posted back the form, not using
WebForm_DoPostBackWithOptions() to preserve the __EVENTTARGET and
friends, which would allow the page to fire the btn's click event
before the Response went to the client.

However, after the if statement fails (form_onsubmit returns true, no
else case, so things fall through), the postback happens, but
Page.IsPostBack is false, and the btn.Click events never fire.
Anything I'm doing obviously wrong? It seems as though the
WebForm_DoPostBackWithOptions() stuff should be happening due to the
falling through ...

Thanks,
Dan
 
D

Dan Christensen

form_onsubmit is my custom validation function which disables the
button, validates my fields, and returns true if valid, false
otherwise.

The disabling the button was breaking the postback, I think.

I moved to a different way of setting up my validation and everything
works now.

Thanks,
Dan
 

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
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top