C# : Tutorial of Asp.net with c# and example

Example and code about windows application, web application, SQL, C#, WPF etc which is helpful to developer and programer.

Search This Blog

How do i bind data in asp.net textbox control run time and design time and some important property of textbox

♠ Posted by uvesh in , at Sunday, August 17, 2014

Bind data in text box in code behind and in aspx means design time


Bind data in text box at design time as follow:


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

its display: Hello World!


Bind data in text box at codeing  time or in code behind page as follow:


textbox1.text = "Hello World!"

it display as :"Hello World!"


Bind data in text box at codeing from database or data source as follow:


textbox1.text = datarow["field name of datatable or database"];

Example : textbox1.text = datarow["firstname"];

Important Property of Asp.Net Textbox control as follow:

AccessKey:specify a key that navigates to the TextBox control.

           
Example :
 

<asp:Textbox ID="txt" runat="server" AccessKey="T"  Text="<u>T</u>ext Here:"> </asp:Textbox>
here click on Alt+T you can access this textbox.

AutoCompleteType: associate an AutoComplete class with the TextBox control.


<asp:TextBox id="username" AutoCompleteType="Type" runat="server"/>

 Here Type is different type of autocomplete type such as
FirstName, LastName, MiddleName, None, Office, Email etc you need to write instead of Type any of this many more 

AutoPostBack:post the form containing the TextBox back to the server automatically when the contents of the TextBox is changed.

True if an automatic postback occurs when the TextBox control loses focus; otherwise, false. The default is false.
Example : <asp:Textbox id="Searchtxt" AutoPostBack="True" runat="server"/>

Columns:specify the number of columns to display.

Example : <asp:Textbox id="Searchtxt" Columns="3" runat="server"/>

Enabled:disable the text box.

Example : <asp:Textbox id="Searchtxt" Enabled="True" runat="server"/>

MaxLength:specify the maximum length of data that a user can enter in a text box (does not work when TextMode is set to Multiline).

Example : <asp:Textbox id="Searchtxt" maxlength="50" runat="server"/> 

ReadOnly: prevent users from changing the text in a text box.

Example : <asp:Textbox id="Searchtxt" ReadOnly="True" text="can't change" runat="server"/> 

Rows:specify the number of rows to display.

Example : <asp:Textbox id="Searchtxt" Rows="5" runat="server"/> 

TabIndex: specify the tab order of the text box.

Example : <asp:Textbox id="Searchtxt" TabIndex="5" runat="server"/> 

Wrap:specify whether text word-wraps when the TextMode is set to Multiline.

Example : <asp:Textbox id="Searchtxt" textmode="multiline" Wrap="True" runat="server"/>

Focus: set the initial form focus to the text box.

Example : <asp:Textbox id="Searchtxt" Focus="True" runat="server"/>




Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

0 comments:

Post a Comment