Call the function - simulation

  • Thread starter Thread starter Just D.
  • Start date Start date
J

Just D.

All,

Does anybody know how can I simulate the button click from the JavaScript on
ASPX page? Here is the fragment of the ASPX page with a simple JavaScript
allowing me to do something before the page Unloads:



<script lang="JavaScript">
function OnUnLoad(){
alert("You want to leave this page,
pleaes save your data first!");
var userInput = confirm("Do you wish to
save the data modified on this page?");
if (userInput==true)
{
alert("The data is saved")
}
else
{
alert("All latest
modifications are lost")
}
}
</script>
</HEAD>

<body scroll="yes" onload="RefreshTray()" MS_POSITIONING="GridLayout"
onunload='OnUnLoad()'>



I also have a button on this page allowing me to save the data and the
implementation is written in C# in the code behind. Can I simulate this
button clicking inside this JavaScript and how? Or this idea is basically
wrong and I need to do anything else? What exectly? Any idea?

Thanks,
Just D.
 
you can just do

document.forms[0].submit();

note: no server side button event will fire. you can call the button click

document.getElementById("buttonid").onclick();

-- bruce (sqlwork.com)
 
Back
Top