Sunday, 20 May 2012

ASP.NET Button Server Control - Click Event

Paste Into ASPX Source
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ASP.NET EXAMPLES | BUTTON SERVER CONTROL | BUTTON CLICK EVENT</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4>
ASP.NET Button Control Example - Click Event - Gets the text from TextBox and Prints
in Label on Button Click...
</h4>
</div>
<center>
<div>
Enter your name :
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="show" />
<br />
<asp:Label ID="lblname" runat="server" Font-Bold="True"></asp:Label>
</div>
</center>
</form>
</body>
</html>

Paste Into ASPX.CS Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class _Default : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{
 
}
protected void Button1_Click(object sender, EventArgs e)
{
lblname.Text = txtname.Text;
}
}

3 comments:

ellieshilton said...

I’m seriously happy to discover this great site the future of this blog is getting good and more useful for me thanks and god bless you.
IT Learning

aspexamples said...

Thanks a lot...

Albert Andrada said...

Really Nice Information,Thank You Very Much For Sharing.
Web Development Company

Post a Comment

 
Ranking Website Directory | seo tool | Manoli | ASPDOTNETGUIDE