Quote Trouble

S

scott

I have a style variable below that I can't figure correct quotes for in
response.write line. Any help?


CODE:

sTeamVisible = "visibility: visible;"


Response.Write "<td class=""teamdrop1"" style=""" & sTeamVisible & """ & " "
& RenderTeamFilter(teamID) & "</td>" & vbCrLf
 
B

Bob Lehmann

Response.Write "<td class='teamdrop1' style='" & sTeamVisible & "'" & " " &
RenderTeamFilter(teamID) & "</td>" & vbCrLf

Bob Lehmann
 
R

Ray Costanzo [MVP]

Are you getting an error? If not, what tells you it's not right? What does
a view-source give you? What does RenderTeamFilter return?

Ray at home
 
A

Aaron Bertrand [SQL Server MVP]

I have a style variable below that I can't figure correct quotes for in
response.write line. Any help?

Response.Write "<td class=tempdrop1 style='" & sTeamVisible & "'>"
Response.Write RenderTeamFilter(TeamID)
Response.Write "</td>" & vbCrLf

I find it easier to read and manage quotes if I omit them when not necessary
(e.g. around a word like "teamdrop1"). No, this isn't explicitly correct,
but it sure is useful during debugging, especially when working in an editor
that doesn't make a clear distinction between two ' and one " ...

I also find it easier to manage stuff like this if I break separate elements
onto their own line. Your main problem here, I think, is that you forgot to
close the opening <td> tag. So the resulting output (which you would have
been able to discover if you viewed source) was something like:

<td class="teampdrop1" style="visibility: visible" result of
renderTeamFilter(TeamID)</td>

I find little value in adding all these vbCrLf to the output HTML, unless
you really have a need for the output to be tidy (such as debugging complex
and dynamic HTML layout).

Finally, since the default visibility *is* visible, there is no reason to
explicitly declare this style (you could make it an attribute of tempdrop1
class if you really wanted to), the only time you would need to override the
default and explicitly declare a style attribute is if you were setting it
to something *other* than visible. So your ASP code could just as easily
look like this, and the result in terms of appearance and functionality will
be exactly the same:

<%
....
Response.Write "<td class=tempdrop1>"
Response.Write RenderTeamFilter(TeamID)
Response.Write "</td>"
....
%>

or:

<%
....
Response.Write "<td class=tempdrop1>" & RenderTeamFilter(TeamID) & "</td>"
....
%>

or:

<%
....
Response.Write "<td class=tempdrop1>" & _
RenderTeamFilter(TeamID) & "</td>"
....
%>

or:

<td class=tempdrop1><%=RenderTeamFilter(TeamID)%></td>

There are many ways to skin a cat. Some are a little more likely than
others to yield scratches, cuts & bruises.
 
S

scott

thanks for the tips, you're right about keeping it simple.

my reason for the visible variable is i'm hiding/showing that cell.

thanks for your help and extra explanation.
 
C

CJM

Aaron Bertrand said:
I find it easier to read and manage quotes if I omit them when not
necessary (e.g. around a word like "teamdrop1"). No, this isn't
explicitly correct, but it sure is useful during debugging, ....

It's is either explicitly correct or incorrect depending on what DOCTYPE you
are validating against.

For HTML4.01 and earlier, quotes are optional (though I prefer them).

For XHTML, they are mandatory for validation.

But, hell...who validates in this group?
There are many ways to skin a cat. Some are a little more likely than
others to yield scratches, cuts & bruises.

With your permission, I think I might borrow this line.

Chris
 
A

Aaron Bertrand [SQL Server MVP]

my reason for the visible variable is i'm hiding/showing that cell.

You can still do that without explicitly starting it off as visible (since
it does that by default anyway). But unless you are affecting the whole
class en masse in client-side script, the element will need an id to
reference.

A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top