[thelist] [ASP] newbie resources

Jason Handby jasonh at pavilion.co.uk
Fri Nov 15 12:10:07 CST 2002


> You've basically got the right idea there. It works, but in a case like
> that, Select Case would cut out the redundancy.
>
> <%
> showSub = Trim(Request.QueryString("subMenu"))
> Select showSub
> 	Case "chinaHouseExpress"
> 		showImg = "expressSub.gif"
> 	Case "setMenu"
> 		showImg = "setMenuSub.gif"
> 	Case "starters"
> 		showImg = "saladsSub.gif"
> End Select
> %>
> <div id="subHead">
> <img src="images/<%= showImg %>" width="157" height="20" />
> </div>

Another big advantage of doing it this way is that, if you edit the page in
Dreamweaver, you'll only see one div element appearing in design view (which
is presumably what you want). Dreamweaver reads the page as if your ASP is
just blocks of stuff it should preserve but ignore -- it (obviously) doesn't
process loops and conditionals in your server-side code. So for example I
avoid doing things like this (rubbish example):

	<table>
	  <tr>
	<%
	  if blah then
	%>
	    <td>One thing</td>
	<%
	  else
	%>
	    <td>Another thing</td>
	<%
	  end if
	%>
	  </tr>
	</table>

because that would cause Dreamweaver to show a two-column table when
editing, although actually when run the ASP page would produce one column of
output. A better alternative would be

	<table>
	  <tr>
	    <td>
	<%
	  if blah then
	%>
	    One thing
	<%
	  else
	%>
	    Another thing
	<%
	  end if
	%>
	    </td>
	  </tr>
	</table>

In other words, try not to put tags inside loops or conditionals if doing so
will confuse your editor. I only mention this because I wish I'd thought of
this sooner when I started out! :-)



Jason




More information about the thelist mailing list