ASP.Net/Asp Control/Multi Line TextBox
Версия от 15:30, 26 мая 2010; (обсуждение)
Multiline TextBox (C#)
<%@ 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>
<br />
<asp:Label id="lblAddress" runat="server"></asp:Label>
<br />
<asp:Label id="lblPassword" runat="server"></asp:Label>
<br />
<form runat="server">
Please enter your name:
<asp:textbox id="txtName" runat="server"></asp:textbox>
<br />
<br />
Please enter your address:
<asp:textbox id="txtAddress" runat="server" textmode="multiline" rows="5"></asp:textbox>
<br />
<br />
Please enter your password:
<asp:textbox id="txtPassword" runat="server" textmode="password"></asp:textbox>
<br />
<br />
<input type="submit" value="Submit Query" />
</form>
</body>
</html>
Set asp:textbox rows count and textmode (VB.net)
<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" />
<br />
<asp:label id="message2" runat="server" />
<br />
<asp:label id="message3" runat="server" />
<br />
<form runat="server">
Please enter your name:
<asp:textbox id="text1" runat="server" />
<br /><br />
Please enter your address:
<asp:textbox id="text2" runat="server" rows=5 textmode="multiline" />
<br /><br />
Please enter your chosen password:
<asp:textbox id="text3" runat="server" textmode="password" />
<br /><br />
<input type="Submit">
</form>
</body>
</html>
Set asp:TextBox TextMode to MultiLine, Rows to 5 (VB.net)
<%@ Page Language="VB" %>
<html>
<head>
<title>Setting Properties and Formatting</title>
</head>
<body bgcolor="#ffffc0">
<form runat="server">
<p>
<asp:Label id="Label1" runat="server">Address:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>
</p>
</form>
</body>
</html>