Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP variables?

Reply
Thread Tools

ASP variables?

 
 
thefunnel@aol.com
Guest
Posts: n/a
 
      06-19-2006
Hi,

I have the following ASP to display a certain image depending on a case
statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and will
appear up to 30 times... Can I create some kind of "variable" at the
top and simply call it when required?

Many thanks,

Paul

 
Reply With Quote
 
 
 
 
Turkbear
Guest
Posts: n/a
 
      06-19-2006
On 19 Jun 2006 08:01:54 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

>Hi,
>
>I have the following ASP to display a certain image depending on a case
>statement...
>
><%
>Select Case (recordset("type"))
> Case "type1"
> Response.Write ("<img src=""type1.gif"" border=""0"">")
> Case "type2"
> Response.Write ("<img src=""type2.gif"" border=""0"">")
> Case "type"
> Response.Write ("<img src=""type3.gif"" border=""0"">")
>End Select
>%>
>
>As the case section will be the same through out the document, and will
>appear up to 30 times... Can I create some kind of "variable" at the
>top and simply call it when required?
>
>Many thanks,
>
>Paul


Perhaps yu can write it as a Subroutine and call it when needed..


 
Reply With Quote
 
 
 
 
Lee Carnell
Guest
Posts: n/a
 
      06-19-2006
Turkbear wrote:
> On 19 Jun 2006 08:01:54 -0700, (E-Mail Removed) wrote:
>
>> Hi,
>>
>> I have the following ASP to display a certain image depending on a
>> case statement...
>>
>> <%
>> Select Case (recordset("type"))
>> Case "type1"
>> Response.Write ("<img src=""type1.gif"" border=""0"">")
>> Case "type2"
>> Response.Write ("<img src=""type2.gif"" border=""0"">")
>> Case "type"
>> Response.Write ("<img src=""type3.gif"" border=""0"">")
>> End Select
>> %>
>>
>> As the case section will be the same through out the document, and
>> will appear up to 30 times... Can I create some kind of "variable"
>> at the top and simply call it when required?
>>
>> Many thanks,
>>
>> Paul

>
> Perhaps yu can write it as a Subroutine and call it when needed..



How about this....

Dim strImage
Select Case (recordset("type"))
Case "type1"
strImage = "<img src=type1.gif border=0 />"
Case "type2"
strImage = "<img src=type2.gif border=0 />"
Case "type"
strImage = "<img src=type3.gif border=0 />"
End Select

Then to display the image in the page just response.write strImage at the
appropraite point.


--
--
Lee Carnell
Never enter a place you can't run out of.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      06-19-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> I have the following ASP to display a certain image depending on a case
> statement...
>
> <%
> Select Case (recordset("type"))
> Case "type1"
> Response.Write ("<img src=""type1.gif"" border=""0"">")
> Case "type2"
> Response.Write ("<img src=""type2.gif"" border=""0"">")
> Case "type"
> Response.Write ("<img src=""type3.gif"" border=""0"">")
> End Select
> %>
>
> As the case section will be the same through out the document, and will
> appear up to 30 times... Can I create some kind of "variable" at the
> top and simply call it when required?
>
> Many thanks,
>
> Paul
>


What you need is a Function:-

Function GetTypeImg(rsType)

Select Case
Case "type1": GetTypeImg = "type1.gif"
Case "type2": GetTypeImg = "type2.gif"
Case "type3": GetTypeImg = "type3.gif"
End Select

End Function

At the point in the HTML where you want the img:-

<img src="<%=GetTypeImg(rst("type"))%>" border="0" />




 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      06-20-2006
Gazing into my crystal ball I observed "Anthony Jones"
<(E-Mail Removed)> writing in
news:eP#(E-Mail Removed):

>
><(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>> Hi,
>>
>> I have the following ASP to display a certain image depending on a
>> case statement...
>>
>> <%
>> Select Case (recordset("type"))
>> Case "type1"
>> Response.Write ("<img src=""type1.gif"" border=""0"">")
>> Case "type2"
>> Response.Write ("<img src=""type2.gif"" border=""0"">")
>> Case "type"
>> Response.Write ("<img src=""type3.gif"" border=""0"">")
>> End Select
>> %>
>>
>> As the case section will be the same through out the document, and
>> will appear up to 30 times... Can I create some kind of "variable" at
>> the top and simply call it when required?
>>
>> Many thanks,
>>
>> Paul
>>

>
> What you need is a Function:-
>
> Function GetTypeImg(rsType)
>
> Select Case
> Case "type1": GetTypeImg = "type1.gif"
> Case "type2": GetTypeImg = "type2.gif"
> Case "type3": GetTypeImg = "type3.gif"
> End Select
>
> End Function
>
> At the point in the HTML where you want the img:-
>
><img src="<%=GetTypeImg(rst("type"))%>" border="0" />
>


I would remove border="0" to CSS [img {border:0}] and put in alt="".

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
global filter to redirect asp (old asp!) pages on asp.net site Daves ASP .Net 2 05-31-2006 08:33 AM
2.0: asp:Menu, asp:XmlDataSource, asp:PlaceHolder R.A.M. ASP .Net 1 03-29-2006 07:55 AM
[ASP.NET1.1]Should I kill the ASP.NET worker process after recompilingmy ASP.NET webservice? Andrea Raimondi ASP .Net 1 02-06-2006 08:10 AM
ASP.Net cookie -> ASP -> ASP.Net Ben ASP .Net 3 05-28-2004 03:35 PM
LOOP through an ASP form's pages (not ASP.NET - ASP classic) David A. Beck ASP General 10 04-13-2004 05:38 PM



Advertisments