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?
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?