C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
ASP.NET Web Forms TextBoxThis is an input control which is used to take user input. To create TextBox either we can write code or use the drag and drop facility of visual studio IDE. This is server side control, asp provides own tag to create it. The example is given below. < asp:TextBoxID="TextBox1" runat="server" ></asp:TextBox> Server renders it as the HTML control and produces the following code to the browser. <input name="TextBox1" id="TextBox1" type="text"> This control has its own properties that are tabled below.
Example// WebControls.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebControls.aspx.cs" Inherits="WebFormsControlls.WebControls" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="labelId" runat="server">User Name</asp:Label> <asp:TextBox ID="UserName" runat="server" ToolTip="Enter User Name"></asp:TextBox> </div> <p> <asp:Button ID="SubmitButton" runat="server" Text="Submit" OnClick="SubmitButton_Click" /> </p> <br /> </form> <asp:Label ID="userInput" runat="server"></asp:Label> </body> </html> Code Behind// WebControls.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebFormsControlls { public partial class WebControls : System.Web.UI.Page { protected void SubmitButton_Click(object sender, EventArgs e) { userInput.Text = UserName.Text; } } } This is a property window of the TextBox control. Output: It produces the following output. It displays user input, when user submits the input to the server. The following screen shot taking and showing user input.
Next TopicASP.NET Button
|