469,623 Members | 908 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Javascript forced button click

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?

--
[[((hillarie))]]

To reply, remove ".SPAMBLOCK" from email address
Nov 17 '05 #1
0 1006

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JCE | last post: by
6 posts views Thread by Shamin | last post: by
6 posts views Thread by tshad | last post: by
8 posts views Thread by chrisdude911 | last post: by
7 posts views Thread by julian.tklim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.