WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

ASP.NET Web Forms - The TextBox Control


The TextBox control is utilized to make a content box where the client can include text.


The TextBox Control

The TextBox control is utilized to make a content box where the client can enter text.

The precedent underneath exhibits a portion of the properties you may use with the TextBox control:

Example

<html>
<body>

<form runat="server">

A fundamental TextBox:
<asp:TextBox id="tb1" runat="server"/>
<br/><br/>

A secret key TextBox:
<asp:TextBox id="tb2" TextMode="password" runat="server"/>
<br/><br/>

A TextBox with text:
<asp:TextBox id="tb4" Text="Hello World!" runat="server"/>
<br/><br/>

A multiline TextBox:
<asp:TextBox id="tb3" TextMode="multiline" runat="server"/>
<br/><br/>

A TextBox with height:
<asp:TextBox id="tb6" rows="5" TextMode="multiline"
runat="server"/>
<br/><br/>

A TextBox with width:
<asp:TextBox id="tb5" columns="30" runat="server"/>

</form>

</body>
</html>

Add a Script

The substance and settings of a TextBox control might be changed by server contents when a structure is submitted. A structure can be put together by tapping on a catch or when a client changes the incentive in the TextBox control.

In the accompanying model we pronounce one TextBox control, one Button control, and one Label control in an .aspx record. Whenever the submit catch is set off, the submit subroutine is executed. The submit subroutine composes a content to the Label control:

Example

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
lbl1.Text="Your name is " & txt1.Text
End Sub
</script>

<html>
<body>

<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server"/>
<asp:Button OnClick="submit" Text="Submit" runat="server"/>
<p><asp:Label id="lbl1" runat="server"/></p>
</form>

</body>
</html>

In the accompanying model we pronounce one TextBox control and one Label control in an .aspx record. When you change the incentive in the TextBox and either click outside the TextBox or press the Tab key, the change subroutine is executed. The submit subroutine composes a content to the Label control:

Example

<script runat="server">
Sub change(sender As Object, e As EventArgs)
lbl1.Text="You changed content to " & txt1.Text
End Sub
</script>

<html>
<body>

<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server"
text="Hello World!"
ontextchanged="change" autopostback="true"/>
<p><asp:Label id="lbl1" runat="server"/></p>
</form>

</body>
</html>