ASP.Net/Asp Control/Multi Line TextBox

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Multiline TextBox (C#)

   <source lang="csharp">

<%@ Page Language="c#" %> <script runat="server">

   void Page_Load()
   {
     if (Page.IsPostBack)
     {
         lblName.Text = "";
         lblAddress.Text = "";
         lblPassword.Text = "";
     }
   
     if (txtName.Text !="")
       lblName.Text = "You have entered the following name: " +  txtName.Text;
   
   
     if (txtAddress.Text !="")
       lblAddress.Text = "You have entered the following address: " + txtAddress.Text;
   
   
     if (txtPassword.Text !="")
       lblPassword.Text = "You have entered the following password: " + txtPassword.Text;
   
   
   }

</script> <html> <head>

   <title>Text Box Example</title>

</head> <body>

   <asp:Label id="lblName" runat="server"></asp:Label>
   
<asp:Label id="lblAddress" runat="server"></asp:Label>
<asp:Label id="lblPassword" runat="server"></asp:Label>
<form runat="server"> Please enter your name: <asp:textbox id="txtName" runat="server"></asp:textbox>

Please enter your address: <asp:textbox id="txtAddress" runat="server" textmode="multiline" rows="5"></asp:textbox>

Please enter your password: <asp:textbox id="txtPassword" runat="server" textmode="password"></asp:textbox>

<input type="submit" value="Submit Query" /> </form>

</body> </html>

      </source>
   
  


Set asp:textbox rows count and textmode (VB.net)

   <source lang="csharp">

<script runat="Server" language="VB"> Sub Page_Load()

   Dim strArrayDetails(2) As String
   Dim intLoop As Integer
   
   strArrayDetails(0) = text1.Text 
   strArrayDetails(1) = text2.Text
   strArrayDetails(2) = text3.Text
   
   Message1.text = CStr(strArrayDetails(0)) 
   Message2.text = CStr(strArrayDetails(1)) 
   Message3.text = CStr(strArrayDetails(2)) 

End Sub </script> <html>

 <head>
   <title>Text Box Example</title>
 </head>
 <body>
   <asp:label id="message1" runat="server" />
   
<asp:label id="message2" runat="server" />
<asp:label id="message3" runat="server" />
<form runat="server"> Please enter your name: <asp:textbox id="text1" runat="server" />

Please enter your address: <asp:textbox id="text2" runat="server" rows=5 textmode="multiline" />

Please enter your chosen password: <asp:textbox id="text3" runat="server" textmode="password" />

<input type="Submit"> </form> </body>

</html>

      </source>
   
  


Set asp:TextBox TextMode to MultiLine, Rows to 5 (VB.net)

   <source lang="csharp">

<%@ Page Language="VB" %> <html> <head> <title>Setting Properties and Formatting</title> </head> <body bgcolor="#ffffc0">

   <form runat="server">

<asp:Label id="Label1" runat="server">Address:</asp:Label>  <asp:TextBox id="TextBox1" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>

   </form>

</body> </html>

      </source>