Hi nauna,
To alert for specific button use below code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var clicked = "";
$(function () {
$("input[type=submit]").click(function (e) {
clicked = e.target.id;
});
});
function WebForm_OnSubmit() {
if (clicked == "btnSubmit") {
return confirm('Do you want to submit?');
return true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server" onsubmit="return WebForm_OnSubmit()">
<div>
<asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="Submit" />
<asp:Button ID="btnSubmit1" Text="Submit1" runat="server" OnClick="Submit" />
</div>
</form>
</body>
</html>
Code
C#
protected void Submit(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Button " + (sender as Button).Text + " Clicked.');", true);
}
VB.Net
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Button " & (TryCast(sender, Button)).Text & " Clicked.');", True)
End Sub
Screenshot