Break the Habit: SPAN and DIV
Sometimes you want to set the font styles of a range of text without associating that text with a particular logical markup such as <EM> or <A ...>. In that case you’ll find the <SPAN ...> and <DIV ...> tags handy. <SPAN ...> and <DIV ...> were specifically created to allow for the free form application of styles.
<SPAN ...> is a text-level element. It should only be used to set text within a paragraph. For example, suppose we want a range of text which is big and red. We could create a class like this (in a STYLE tag or in a style sheet file):
.bigred { font-size:30pt; color:red; font-weight:900; }
Now we can apply the style to a span of text by setting its class to bigred:
Are you <SPAN CLASS=”bigred”>crazy?</SPAN>
which gives us this sentence: Are you crazy?
<DIV ...> is a block level element. It starts a new paragraph at the beginning and closes the paragraph at the end. Styles are applied to <DIV ...> in the same way as for <SPAN ...>: set the class using the CLASS class attribute. So, for example, we can use the same style rule as above and apply it to a <DIV ...> like this:
<DIV CLASS=”bigred”> Be sure to disconnect socket A from plug B or severe damage will occur. </DIV>
which gives us
Be sure to disconnect socket A from plug B or severe damage will occur.
div align=center
What is the difference between <div align=”center”> and <div style=”text-align:center”> aside from the obvious difference that the latter is CSS?
I don’t think align=”" is valid XHTML 1.0 coding. style=”text-align: ” is, however.
DataBinder.Eval() in C# Question
If have i a funtion below:-
Protected Function CheckUnit(Units As Object) As String
‘—————————————–
‘ If the Units returned equals to Zero,
‘ a message of “Out of Units” will be displayed.
‘ Otherwise, displayed the original value
‘—————————————–
If Integer.Parse(Units) = 0 Then
Return “Out Of Units”
Else
Return Units.ToString()
End If
End Function
I use :- <%# CheckUnit(Container.DataItem(”Units”)) %>
to display the value of the function.
But in C sharp it gives error so i used
<%# DataBinder.Eval(Container.DataItem, “Units”) %>
and it works!!
whats the right code when using C# to dislpay the value using
<%# DataBinder.Eval(Container.DataItem, “Units”) %>
with the CheckUnit Function???