Results 1 to 10 of 10

Thread: [RESOLVED] what is more efficient?

  1. #1

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Resolved [RESOLVED] what is more efficient?

    Hi,

    i have small questions what is more efficient:

    Code:
    <table>
      <tr>
           <td>
                 Some string
           </td>
      </tr>
    </table>
    or

    Code:
    <table>
      <tr>
           <td>
               <asp:Label ID="lblSomething" runat="server" Text="Some string"></asp:Label>
           </td>
      </tr>
    </table>
    by using the second example i making it more ASP.NET "correct" but i'm also adding unnecessary tags and making the page a bit heavier .. is using the first example is still "Ok" with ASP.NET?
    should i only use ASP.NET tags when i need to manipulate its content from the code behind ?

    thanks!
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: what is more efficient?

    should i only use ASP.NET tags when i need to manipulate its content from the code behind ?
    Yes that's the general idea.

    It's better to use text/html for static content, your example using a label presents a ? as to why a label was used.

  3. #3

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: what is more efficient?

    Thanks.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] what is more efficient?

    Hey,

    I would agree with brin on this one. I tend to only use ASP.Net Label controls when I need to manipulate the Text Value from the Server Side code.

    Gary

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: [RESOLVED] what is more efficient?

    If the code is static, use html tags. If you would be changing that label text or css etc. from code, then use label. The final output of a Label control is <span> tags. So you can use that directly, if your text won't be changing.
    Code:
    <table>
      <tr>
           <td>
               <span ID="lblSomething">Some string</span>
           </td>
      </tr>
    </table>
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: [RESOLVED] what is more efficient?

    Pradeep i think that if i'll don't need to use label i also don't need to reproduce its outcome e.g <span> tag unless i need one.

    but i have another question, my site will be multi language, i didn't touched that part yet i'm saving it to the end, but is this mean that i need to put all the text inside labels or literals so i can use the multilingual feature of .NET ?

    thanks.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: [RESOLVED] what is more efficient?

    Quote Originally Posted by motil View Post
    Pradeep i think that if i'll don't need to use label i also don't need to reproduce its outcome e.g <span> tag unless i need one.
    In simple cases it doesn't matter if you put in <span> tag or not. But consider cases like this one:
    Code:
     <asp:Label ID="lblSomething" runat="server" CssClass="SomeStyle" Text="Some string"></asp:Label>
     <asp:Label ID="lblSomething2" runat="server" CssClass="SomeOtherStyle" Text="Some string"></asp:Label>
    So here you can't do without it. Though you can omit some of the tags like ID etc. which you won't need at client side (unless you do something with it using javascript etc.)
    Code:
    <span ID="lblSomething" class="SomeStyle">Some string</span>
     <span ID="lblSomething2" class="SomeOtherStyle">Some string</span>
    Quote Originally Posted by motil View Post
    but i have another question, my site will be multi language, i didn't touched that part yet i'm saving it to the end, but is this mean that i need to put all the text inside labels or literals so i can use the multilingual feature of .NET ?
    Yes. I can't think of other ways. But maybe someone else has better thoughts.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] what is more efficient?

    Use labels and literals on the page. Store your localized strings in RESX files. You can then use the meta:ResourceKey to get the actual string out of your RESX files depending on the culture. Look at this walkthrough.

    http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] what is more efficient?

    Oh, and here is some more reading for you as well...

    http://msdn.microsoft.com/en-us/library/c6zyy3s9.aspx

    Maybe not something you want to leave right until the end.

    Gary

  10. #10

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: [RESOLVED] what is more efficient?

    Thanks for the links Gary and Mend.

    i will go over them now.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width