This program help to pass command name on button command.
Assign CommandName="MyClick" property for button and in C# check for command name you pass through button.
if(e.CommandName == "MyClick")
How to pass command on button click in C# Example:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<script runat="server">
protected void btnClick_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "MyClick")
{
Response.Write("Click Command Passed");
}
else
{
Response.Write("Non Click Command Passed");
}
}
</script>
<html xmlns="">
<head>
<title>How pass command on button click.</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnClick" runat="server" Text="Button" CommandName="MyClick" OnCommand="btnClick_Command" />
</div>
</form>
</body>
</html>
0 comments:
Post a Comment