how to determine which serverside Button click in Client Side javascript?
How to determine which serverside Button click in Client Side javascript? There are many Buttons in the form.
function onMyClicked()
{
var btn = ??;
if (btn == 'IDDelete') {
var result = confirm("........ ");
if (result){
xxxxx
}
else close();
}
else if(btn=='IDClose'){
xxxxx
}
window.onunload = function (){
onMyClicked();
}
<asp:Button ID="IDDelete" runat="server" Text="Delete" --->
<asp:Button ID="IDClose" runat="server" Text="Close" ---->
EDIT:
var isDirty;
isDirty = 0;
function setDirty() {
isDirty = 1;
}
function onMyClicked() {
var btn =???;
if (btn == 'IDClose') {
var sSave;开发者_如何学Python
if (isDirty == 1) {
sSave = window.returnValue = confirm('------');
if (window.returnValue == false) closerel();
if (sSave == true) {
document.getElementById('__EVENTTARGET').value = 'IDSave';
document.getElementById('__EVENTARGUMENT').value = 'Click';
window.document.form1.submit();
}
else {
close();
}
}
else close();
}
}
window.onunload = function (){
onMyClicked();
}
<asp:Button ID="IDDelete" runat="server" Text="Delete" >
<asp:Button ID="IDClose" runat="server" Text="Close" >
<asp:Button ID="IDSave" runat="server" Text="Save" >
<asp:Button ID="IDClose" runat="server" Text="Close" >
How to determinde IDClose click?
If you use OnClientClick property of the button, the function you type in the property runs. So your code will become:
function delete()
{
var result = confirm("........ ");
if (result){
xxxxx
}
else close();
}
}
function close()
{
xxxxx
}
<asp:Button ID="IDDelete" runat="server" Text="Delete" OnClientClick="Delete">
<asp:Button ID="IDClose" runat="server" Text="Close" OnClientClick="Close">
精彩评论