Thursday, 17 May 2012

Simple TextBox Example - Text Changed 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></title>
</head>
<body>
<form id="form1" runat="server">
<center>
<div style="border: 2px; font-size:12px; border-color: Black; border-style: solid; color: White;
background-color: Red; font-weight: bold; font-family: Tahoma"
>
By : <a href="http://asp-examples.blogspot.com/" style="color:Yellow" target="_search">asp-examples</a>
(Click to get more Asp.net Examples)
<br />
Author : Akash Parmar<br />
Company Name : Soft-Tech Designs n Development<br />
We Design your Dreams - Develop your Life...
</div>
<div>
<h4>
Simple Textbox Example - Textchanged Event - Gets the text from TextBox and Prints in Label...
</h4>
</div>
<center>
<div>
Enter your name :
<asp:TextBox ID="txtname" runat="server" AutoPostBack="True" OnTextChanged="txtname_TextChanged"></asp:TextBox>
<br />
<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 txtname_TextChanged(object sender, EventArgs e)
{
lblname.Text = "Hello " + txtname.Text;
}
}

1 comments:

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