This is a migrated thread and some comments may be shown as answers.

ASP.NET very basic question

1 Answer 42 Views
Getting started with ASP.NET
This is a migrated thread and some comments may be shown as answers.
Seabus
Top achievements
Rank 1
Seabus asked on 14 Jun 2011, 07:33 PM
Hi,

What's the difference between typing some text vs inserting a label and typing some text into that label ?

Any reason why somebody would want to use a label vs just type text on the page ?

The only advantage that I can think of is that a label can be updated easily ( e.g user clicks a button , in the event code for the click action one can write something like label1.Text = "some value" )


Thanks

1 Answer, 1 is accepted

Sort by
0
Boyan Barnev
Telerik team
answered on 15 Jun 2011, 12:07 PM
Hello Seabus,

You have pointed the main advantage yourself - using a Label control allows you to set the text dynamically and easily update it on site runtime, while typing static text reqires manula update and does not allow runtime change. However it all depends on the use case scenario you want to implement, if you're not going to benefit from the advantages the label control is offering you don't have to use it. One thing you might pay attention to is that Label.Text is not HTML encoded before it is displayed in the Label control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to help prevent security vulnerabilities. For more information, please take a look at this article from MSDN.

All the best,
Boyan Barnev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
Getting started with ASP.NET
Asked by
Seabus
Top achievements
Rank 1
Answers by
Boyan Barnev
Telerik team
Share this question
or