Button control are used to display a push button control on the web page.
Button class inherited from :
Object->Control->WebControl->Button
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Button control in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button1_Click"/>
</div>
</form>
</body>
</html>
Add the following code in cs file :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace tutorials
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Current date : "+System.DateTime.Now);
}
}
}
No comments:
Post a Comment