HTML
OnServerClick="ibtn_Click(this)"
js
function ibtn_Click(el){
if(el.id == 'btnSubmit'){ // code here for Submit button}
else if(el.id == 'btnCancel'){ // code here for Cancel button}
}
OP评论后更新。
您为两个按钮创建不同的功能,并在另一个功能中保留公共代码(如果有),并在要使用的两个功能中调用此功能。
例子
function common_code (){ //common code for both functions }
function btnSubmit (){
// code here for Submit button and call
common_code ();
}
function btnCancel (){
// code here for Cancel button and call
common_code ();
}
HTML
<input runat="server" name="btnSubmit" id="btnSubmit" value="Submit" type="submit" OnServerClick="btnSubmit" />
<input runat="server" name="btnCancel" id="btnCancel" value="Cancel" type="submit" OnServerClick="btnCancel" />