C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
ASP.NET Web Forms LabelThis control is used to display textual information on the web forms. It is mainly used to create caption for the other controls like: textbox. To create label either we can write code or use the drag and drop facility of visual studio 2017. This is server side control, asp provides own tag to create label. The example is given below. < asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label> 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> <style type="text/css"> .auto-style1 { width: 100%; } .auto-style2 { margin-left: 0px; } .auto-style3 { width: 121px; } </style> </head> <body> <form id="form1" runat="server"> <div> <h4>Provide the Following Details:</h4> <table class="auto-style1"> <tr> <td class="auto-style3"> <asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label></td> <td> <asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style2"></asp:TextBox></td> </tr> <tr> <td class="auto-style3"> <asp:Label ID="Label2" runat="server" Text="Upload a File"></asp:Label></td> <td> <asp:FileUpload ID="FileUpload1" runat="server" /></td> </tr> </table> </div> </form> </body> </html> This is a property window of label control. Output: Here, we have used label control with two different controls. It produces the following output.
Next TopicASP.NET TextBox
|