Saturday, May 31, 2014

TextBox control

Properties of TextBox control
        TextMode property
        AutoPostBack-Automatically postback when text is changed.
Events of TextBox
        TextChanged :- This event is fired, when the text is changed.
Methods of TextBox
        Focus :- set input focus onto the control.

Here an example to print text in the textbox
WebForm1.aspx :-
 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="_10_TextBoxControl.WebForm1" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">  
 <html xmlns="">  
 <head runat="server">  
   <form id="form1" runat="server">  
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />  

WebForm1.aspx.cs :-
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 namespace _10_TextBoxControl  
   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("Hello "+TextBox1.Text);  

No comments:

Post a Comment