Saturday, May 31, 2014

TextBox control

Properties of TextBox control
        TextMode property
        Text
        ReadOnly
        ToolTip
        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" "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">  
   <div>  
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />  
   </div>  
   </form>  
 </body>  
 </html>  

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)  
     {  
       TextBox1.Focus();  
     }  
     protected void Button1_Click(object sender, EventArgs e)  
     {  
       Response.Write("Hello "+TextBox1.Text);  
     }  
   }  
 }  

No comments:

Post a Comment