|
-
Dec 29th, 2009, 04:53 PM
#1
[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 
-
Dec 29th, 2009, 06:06 PM
#2
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.
-
Dec 30th, 2009, 03:09 AM
#3
Re: what is more efficient?
* 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 
-
Dec 30th, 2009, 09:44 AM
#4
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
-
Dec 30th, 2009, 10:10 AM
#5
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>
-
Dec 30th, 2009, 12:39 PM
#6
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 
-
Dec 30th, 2009, 09:10 PM
#7
Re: [RESOLVED] what is more efficient?
 Originally Posted by motil
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>
 Originally Posted by motil
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.
-
Dec 31st, 2009, 05:02 AM
#8
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
-
Dec 31st, 2009, 11:04 AM
#9
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
-
Jan 1st, 2010, 11:56 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|