ASP Syntax Error (was: RE: [thelist] CSS Question - Simple)

Alex Ezell taranis at spittingllamas.com
Mon Sep 15 15:43:37 CDT 2003


On Monday, September 15, 2003, 4:24:43 PM, Rob wrote:

> Take a look at this:

> Dim strings, doohickey
> doohickey = 1
> strings = "<h1>" & if doohickey = 1 then response.write("Hello") & "</h1>"
> response.Write(strings)

> I thought you could do this in ASP? What would be the alternative?

I think it would be easier and more manageable code to do something
like:
<%
Dim strings, doohickey
doohickey = 1

If doohickey = 1 Then
   strInsert = "Hello"
End If
%>
<h1><%=strInsert%></h1>

IMO, that helps keep the HTML out of the ASP if you should want to
change it at a later date. It also help seperate the IF statment from
the display of its result. That will make troubleshooting easier as
things get more complex.

That said, there are lots of ways to do this, so this method is in no
way declared as the best. It will always depend on what you are wanting
to do and what else is happening in the page.

Also, be careful with numbers and strings:
1 does not equal "1"

-- 
Alex
http://www.spittingllamas.com
"Formal Restrictions, contrary to what you might think,
free you up by allowing you to concentrate on purer ideas."
 - Winter Sorbeck in Chip Kidd's The Cheese Monkeys



More information about the thelist mailing list