show-notice
hide-notice

Saturday, 13 July 2013

How to use OnTextChanged event in TextBox in asp.net


Introduction

I will explain How to use OnTextChanged event in TextBox in asp.net.



Example




<%@ page language="C#" autoeventwireup="true" codefile="how-to-use-textchanged-event-c.aspx.cs"
    inherits="how_to_use_textchanged_event_c" %>

<!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>How to use OnTextChanged event in TextBox</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color: Red">
            TextBox Example: OnTextChanged</h2>
        <asp:label id="Label1" runat="server" text="Email">
        </asp:label>
        <asp:textbox id="TextBox1" runat="server" autopostback="true" ontextchanged="TextBox1_TextChanged">
        </asp:textbox>
        <br />
        <br />
        <asp:label id="Label2" runat="server" text="Confirm Email">
        </asp:label>
        <asp:textbox id="TextBox2" runat="server" backcolor="LightGoldenrodYellow" forecolor="Crimson">
        </asp:textbox>
    </div>
    </form>
</html>

C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class how_to_use_textchanged_event_c : System.Web.UI.Page
{

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        TextBox2.Text = TextBox1.Text;
    }
}
 


SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com