For Programmers: Free Programming Magazines  


Home > Archive > ASP > August 2005 > Quotes 2









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Quotes 2
scott

2005-08-21, 6:55 pm

Below in GOOD CODE, I have a mix of ASP/HTML that works. I'm trying to
convert the code into all ASP, but I'm failing in BAD CODE. Can someone help
me with these quotes? The single quotes are very hard to master.


BAD CODE:

sHTML=sHTML & "bgcolor=" & tblcolor & style=""cursor:default;""
onMouseOver="this.bgColor=""'#e6e6e6'"" onMouseOut="this.bgColor='" &
tblcolor & "'"

GOOD CODE:

<%
If sPageType = "forum" Then %>

bgcolor="<%= tblcolor %>" style="cursor:default;"
onMouseOver="this.bgColor='#e6e6e6'" onMouseOut="this.bgColor='<%= tblcolor
%>'"

<% End If %>>


Bob Barrows [MVP]

2005-08-21, 6:55 pm

scott wrote:
> Below in GOOD CODE, I have a mix of ASP/HTML that works. I'm trying to
> convert the code into all ASP, but I'm failing in BAD CODE. Can
> someone help me with these quotes? The single quotes are very hard to
> master.


Look, to escape a quote, double it up:

Response.write "here is a literal quote: "" - see?"

Until you get the hang of it, don't try to do it all at once. Start with the
string fragments:

sHTML= "bgcolor="
response.write sHTML

Running this should result in:
bgcolor=

Now you want an opening quote, so change it to:
sHTML= "bgcolor="""
response.write sHTML

Running it should result in
bgcolor="

Now add the variable:

sHTML= "bgcolor=" & tblcolor

Test it.
Add the closing quote:

sHTML= "bgcolor=" & tblcolor & """"

Test it.
Now add the word "style=":

sHTML= "bgcolor=" & tblcolor & """ style="

Again, test it.
Add the opening quote:
sHTML= "bgcolor=" & tblcolor & """ style="""

Keep going ...

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Evertjan.

2005-08-21, 6:55 pm

scott wrote on 21 aug 2005 in microsoft.public.inetserver.asp.general:

> Below in GOOD CODE, I have a mix of ASP/HTML that works. I'm trying to
> convert the code into all ASP, but I'm failing in BAD CODE. Can
> someone help me with these quotes? The single quotes are very hard to
> master.
>
>
> BAD CODE:
>
> sHTML=sHTML & "bgcolor=" & tblcolor & style=""cursor:default;""
> onMouseOver="this.bgColor=""'#e6e6e6'"" onMouseOut="this.bgColor='" &
> tblcolor & "'"



sHTML=sHTML & "bgcolor=' " & tblcolor & " ' "
sHTML=sHTML & "style='cursor:default;' "
sHTML=sHTML & "onMouseOver='this.bgColor=#e6e6e6' "
sHTML=sHTML & "onMouseOut='this.bgColor=' " & tblcolor & " '' "


However I would define the colour in style too:


sHTML=sHTML & "style='cursor:default;background-color:" & tblcolor & ";' "
sHTML=sHTML & "onMouseOver='this.style.backgroundColor=#e6e6e6' "
sHTML=sHTML & "onMouseOut='this.style.backgroundColor=' "
sHTML=sHTML & tblcolor & " '' "

Not tested.

You should test this by view-sourcing the clientside"in-browser" result.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

scott

2005-08-21, 6:55 pm

I'm getting better at double quotes, but this is confusing because I'm not
sure about js event syntax. I've tried everything and just get errors.

MY CODE:

Response.Write "bgcolor=" & tblcolor & style=""cursor:default;""
onMouseOver="this.bgColor=""'#e6e6e6'"" onMouseOut="this.bgColor='" &
tblcolor & "'"

HTML RESULTS:

bgcolor="whitesmoke" style="cursor:default;"
onMouseOver="this.bgColor='#e6e6e6'" onMouseOut="this.bgColor='whitesmoke'"






"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:eJdvRbnpFHA.1444@tk2msftngp13.phx.gbl...
> scott wrote:
>
> Look, to escape a quote, double it up:
>
> Response.write "here is a literal quote: "" - see?"
>
> Until you get the hang of it, don't try to do it all at once. Start with
> the string fragments:
>
> sHTML= "bgcolor="
> response.write sHTML
>
> Running this should result in:
> bgcolor=
>
> Now you want an opening quote, so change it to:
> sHTML= "bgcolor="""
> response.write sHTML
>
> Running it should result in
> bgcolor="
>
> Now add the variable:
>
> sHTML= "bgcolor=" & tblcolor
>
> Test it.
> Add the closing quote:
>
> sHTML= "bgcolor=" & tblcolor & """"
>
> Test it.
> Now add the word "style=":
>
> sHTML= "bgcolor=" & tblcolor & """ style="
>
> Again, test it.
> Add the opening quote:
> sHTML= "bgcolor=" & tblcolor & """ style="""
>
> Keep going ...
>
> HTH,
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>




scott

2005-08-21, 6:55 pm

thanks. what does the \ mean? i haven't seen that symbol used with this type
of syntax before.

"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns96B9C90E29F67eejj99@194.109.133.242...
> scott wrote on 21 aug 2005 in microsoft.public.inetserver.asp.general:
>
>
>
> sHTML=sHTML & "bgcolor=' " & tblcolor & " ' "
> sHTML=sHTML & "style='cursor:default;' "
> sHTML=sHTML & "onMouseOver='this.bgColor=#e6e6e6' "
> sHTML=sHTML & "onMouseOut='this.bgColor=' " & tblcolor & " '' "
>
>
> However I would define the colour in style too:
>
>
> sHTML=sHTML & "style='cursor:default;background-color:" & tblcolor & ";' "
> sHTML=sHTML & "onMouseOver='this.style.backgroundColor=#e6e6e6' "
> sHTML=sHTML & "onMouseOut='this.style.backgroundColor=' "
> sHTML=sHTML & tblcolor & " '' "
>
> Not tested.
>
> You should test this by view-sourcing the clientside"in-browser" result.
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>



Bob Barrows [MVP]

2005-08-21, 9:55 pm

scott wrote:
> thanks. what does the \ mean? i haven't seen that symbol used with
> this type of syntax before.
>

In vbscript, you tell te compiler to ignore what a character usually means
("escaping " it) by doubling it. In jscript, you escape a character by
preceding it with a backslash.

Your confusion is arising because you are using vbscript to generate strings
that will be interpreted by the jscript engine.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Bob Barrows [MVP]

2005-08-22, 7:55 am

What errors? This result looks correct to me ... Oh, does HTML RESULTS
contain what you want the results to be? Your code would not return those
results ...

I would have used the style property instead of the deprecated bgColor. Try
this:

Response.Write "style=""cursor:default; background-color:" & _
tblcolor & """ onMouseOver=""this.style.backgroundColor='" & _
"#e6e6e6'"" onMouseOut=""this.style.backgroundColor='" & _
tblcolor & "'"""


scott wrote:[color=darkred]
> I'm getting better at double quotes, but this is confusing because
> I'm not sure about js event syntax. I've tried everything and just
> get errors.
> MY CODE:
>
> Response.Write "bgcolor=" & tblcolor & style=""cursor:default;""
> onMouseOver="this.bgColor=""'#e6e6e6'"" onMouseOut="this.bgColor='" &
> tblcolor & "'"
>
> HTML RESULTS:
>
> bgcolor="whitesmoke" style="cursor:default;"
> onMouseOver="this.bgColor='#e6e6e6'"
> onMouseOut="this.bgColor='whitesmoke'"
>
>
>
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:eJdvRbnpFHA.1444@tk2msftngp13.phx.gbl...

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com