Please visit our sponsors !
Label Control
Definition and Usage
The Label control is used to display text on a page. The text is
programmable.
Note: This control lets you apply styles to its content!
Properties
Property |
Description |
id |
A unique id for the control |
runat |
Specifies that the control is a server control. Must
be set to "server" |
Text |
The text to display in the label |
Example 1
In the following example we declare one Label
control, one TextBox control, and one Button control in an .aspx file. When the user clicks on the button, the submit subroutine is executed. The
subroutine copies the content of the TextBox control to the Label control:
<script runat="server">
Sub submit(Sender As Object, e As EventArgs)
label.Text=txt.Text
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:Label id="label" Text="I'm a Label Control!" runat="server"/>
<p>
Write some text in the text box:
<asp:TextBox id="txt" Width="200" runat="server" />
</p>
<asp:Button id="b1" Text="Copy text to Label" OnClick="submit"
runat="server"/>
</form>
</body>
</html>
|
Example 2
In the following example we declare one ImageButton
control and one Label control in an .aspx file. When the user clicks on the image, the image_Click subroutine is executed. The
subroutine sends the message "Coordinates: " and the x and y
coordinates of the click to the Label control:
<script runat="server">
Sub image_Click(sender As Object, e As ImageClickEventArgs)
mess.Text="Coordinates: (" & e.X & ", " & e.Y & ")"
End Sub
</script>
<html>
<body>
<form runat="server">
<h3>Click on the image:</h3>
<asp:ImageButton id="image1" runat="server"
ImageUrl="..\images\smiley.gif"
OnClick="image_Click"/>
<br /><br />
<asp:Label id="mess" runat="server"/>
</form>
</body>
</html>
|
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|