Wednesday, 3 August 2016

write asp.net program to print textbox value when a change occur in textbox

textbox_with_label.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="textbox_with_label.aspx.cs" Inherits="our_program.textbox_with_label" %>

<!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">
<center>
<h1> TEXTBOX WITH LABEL</h1>
</center>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div>
    <asp:TextBox runat="server" ID="txt" OnTextChanged="textchanged" AutoPostBack="true"></asp:TextBox>
    <br />
    <asp:Label runat="server" ID="lbl" Text="textbox value"></asp:Label>
    </div>
    </center>
    </form>
</body>
</html>

textbox_with_label.aspx.cs

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

namespace our_program
{
    public partial class textbox_with_label : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void textchanged(object sender, EventArgs e)
        {
            string a = txt.Text;
            lbl.Text = a.ToString();
        }
    }
}

No comments:

Post a Comment