TextBox
1. How to disable the default context menu of TextBox (right-click menu)
TextBox1.ContextMenu = new ContextMenu ();
See original
4. How to put the focus at the end of the TextBox text when the textBox gets the focus
TextBox1.SelectionStart = textBox1.Text. Length;
For textbox operations
In Asp.net, all TextBox content on the page is cleared at one time. Because TextBox is displayed on the client in the form of <input type = "text">, therefore, there are two solutions: client and server. Two solutions are available on the server! This article has been widely used in asp tutorials. net interview questions (I feel quite deep ).
1 foreach (Control c in this. FindControl ("form1"). Controls)
2 {
3 if (c is TextBox)
4 {
5 (TextBox) c). Text = "";
6}
7}
8
9
10
Code
1 FieldInfo [] infos = GetType (). GetFields (BindingFlags. Public | BindingFlags. NonPublic | BindingFlags. GetField | BindingFlags. Instance );
2 for (int I = 0; I <infos. Length; I ++)
3 {
4 if (infos [I]. FieldType = typeof (TextBox ))
5 {
6 (TextBox) infos [I]. GetValue (this). Text = "";
7}
8}
Brief Introduction
TextBox control
The TextBox control is used to create a TextBox that allows users to enter text.
The properties of the TextBox control are listed in our TextBox control Reference Manual.
The following example demonstrates some attributes that you may use in the TextBox control:
TIY
<Html>
<Body>
<Form runat = "server">
A basic TextBox:
<Asp: TextBox id = "tb1" runat = "server"/>
<Br/>
A password TextBox:
<Asp: TextBox id = "tb2" TextMode = "password" runat = "server"/>
<Br/>
A TextBox with text:
<Asp: TextBox id = "tb4" Text = "Hello World! "Runat =" server "/>
<Br/>
A multiline TextBox:
<Asp: TextBox id = "Int32" TextMode = "multiline" runat = "server"/>
<Br/>
A TextBox with height:
<Asp: TextBox id = "tb6" rows = "5" TextMode = "multiline"
Runat = "server"/>
<Br/>
A TextBox with width:
<Asp: TextBox id = "tb5" columns = "30" runat = "server"/>
</Form>
</Body>
</Html>
When a form is submitted, the content and settings of the TextBox control can be modified using a server script. You can click a button or when you change the value in the TextBox control to submit the form.