ASP.NET very basic question

2 posts, 0 answers
  1. Seabus
    Seabus avatar
    33 posts
    Member since:
    Jun 2011

    Posted 14 Jun 2011 Link to this post


    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" )

  2. Boyan Barnev
    Boyan Barnev avatar
    2 posts

    Posted 15 Jun 2011 Link to this post

    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 >>

Back to Top