Catching Submit Event even called by document.forms[0].submit()

T

The Crow

i have to catch submit event of the form contained in the asp.net webform.
when a button on the page clicked, it works ok, but when i call
form.submit() or linkbutton vs. calls __doPostBack() , form.onsubmit()
doesnt rise..
 
K

Kevin Spencer

if (Page.IsPostBack)
{
}

If Page.IsPostBack is true, the form has been submitted.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.
 
B

Bruce Barker

the browser doesn't raise the onsubmit event if form.submit() is called.
when you do a submit try:

function mySubmit()
{
var frm = document.forms[0];
if (frm.onsubmit) frm.onsubmit();
frm.submit();
}

you will need to replace the __doPostBack(). just register a startup script
block like:

window.__doPostBack = function (eventTarget, eventArgument)
{
var frm = document.forms[0];
frm .__EVENTTARGET.value = eventTarget.split("$").join(":");
frm .__EVENTARGUMENT.value = eventArgument;
mySubmit();
}

note: if you use subforms then use the form name instead of 0

-- bruce (sqlwork.com)
 

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,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top