Javascript forced button click

H

H Branyan

Scenario:

When a user submits the form by clicking one button (ButtonA), I want to
fire the click event for another button (ButtonB).

I created a javascript function first to the webform:
function SaveForm(btnName) {
alert('Save Form click ' + btnName);
var btn = document.forms[0][btnName];
btn.click();
}

then, I added this statement to my ButtonA click event (codebehind):
Button btn = (Button) Page.FindControl("btnSave");
if ( btn != null )
{
Page.RegisterClientScriptBlock("forceSave",
"<script language=\"javascript\">SaveForm('" + btn.ClientID + "');
</script>");
}

when the script executes, I get the AlertBox but the click event does not
fire. I have confirmed that the EventHandler for btnSave (ButtonB) is
declared before the click event for ButtonA fires.

Does anyone see what I am doing wrong?
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top