programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, July 30, 2014

TextBox Control TextBox Web Control:

The TextBox control in is use to create a user input box in which user can give any type of text input .This is predefine input type control which have some properties and methods.

Textbox in 

Text box is an web control, use for getting input by user as like in the login web page we see username and password Textbox where we enter username and password.
In the Toolbox we get a textbox simply drag and drop it on web page then it is automatically create our html code.
The example is given here with some of the attributes of TextBox control.
Textbox control in
Textbox control in

Declare  A Textbox :


<form runat="server">

                           //A basic TextBox:
                           <asp:TextBox id="txtusername" runat="server" />
                          <br /><br />

                            //A password TextBox:
                          <asp:TextBox id="txtpassword" TextMode="password" runat="server" />             
                           <br /><br />

Here in this Example we take two Textbox with their id first is txtusername for take input User Name and second txtpassword for password field .Both has runat=”server” attribute. Means these Textbox run at server end.

Asp TextBox with text Property:

<asp:TextBox id="Txtbox1" Text="Hello World!" runat="server" />

 Multiline TextBox control:

<asp:TextBox id="Txtbox2" TextMode="multiline" runat="server" />

Asp net custom textbox  with height and width:

<asp:TextBox id="Txtbox3" width=”100px” Height=”100px” runat="server" />

Asp net textbox  properties

 Access key, AutoCompleteType, AutopostBack, BackColor, BorderColor,BorderStyle,BorderWidth,CausesValidation,Font,Height,Width,ReadOnly,Row,Text,TabIndex etc.

C# programming Script for Text control

The Text and property of a TextBox control may be changed by server scripts when a form is submitted. As we know that when we clicked on button or when a user change value in the TextBox control.
In the following example we declare a TextBox control, one Buttoncontrol, and one Label control in an .aspx file. When the submit button then the text of Textbox will change

Example of textbox:

Code on .aspx page :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TextboxExample.aspx.cs" Inherits="TextboxExample" %>

<!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" Text="This is text box."
            Font-Bold="True" Font-Size="X-Large" Height="73px" Width="550px"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" Height="51px"

            onclick="Button1_Click" Width="339px" />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Code on aspx.cs page:

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

public partial class TextboxExample : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void Button1_Click(object sender, EventArgs e)
        Label1.Text = TextBox1.Text;
        TextBox1.Text = "welcome to text box Example";

Other Post: