...

View Full Version : show / hide text



urko
08-28-2005, 06:57 PM
Hi all

As being newbie in asp coding I would need some help.

I would like to make cell that it will be shown only if you are not at default page.
Example:

<% dim Home
if home <> "" then
Response.write("")
Else
Response.write("<tr><td width=""100%"" height=""20""style=""padding:2px;"">HOME</td></tr>")
End if%>
I want this part of the code to be shown in all pages ( i.e. about us, contact us, etc..) but would be hidden on homepage ( default.asp)

Can you please tell me what m i doing wrong??

Thanks,

glenngv
08-29-2005, 07:12 AM
dim page
page = Request.ServerVariables("URL")
if (InStr(page, "default.asp")=0) then 'not in default.asp
Response.write("<tr><td width=""100%"" height=""20""style=""padding:2px;"">HOME</td></tr>")
end if

urko
08-29-2005, 01:42 PM
Thanks :) it works just fine.

Only thing that I noticed is when I click http://myserver/myfolder/
HOME link is displayed.
If I click http://myserver/myfolder/default.asp then it hides the link.
What should I add to hide HOME link if I click http://myserver/myfolder/ ??

SpirtOfGrandeur
08-29-2005, 01:44 PM
StrComp( page , "http://myserver/myfolder/" , 1 ) = 0

glenngv
08-29-2005, 02:07 PM
The URL for the default page returns Default.asp and not default.asp and the default comparison for InStr function is case-sensitive which I thought othewise.

Try this:


dim page
page = Request.ServerVariables("URL")
if InStr(1, page, "default.asp", 1)=0 then 'not in default.asp
Response.write("<tr><td width=""100%"" height=""20""style=""padding:2px;"">HOME</td></tr>")
end if

urko
08-29-2005, 02:57 PM
I forget to mentioned that I have couple of subfolders in which page is named default.asp!

Sorry guys but I'm just start learning asp code so i hope I'm not too annoying with my questions.

I really appreciate your help,

Thanks

SpirtOfGrandeur
08-29-2005, 03:10 PM
StrComp( page , "http://myserver/myfolder/" , 1 ) = 0

StrComp( page , "http://myserver/myfolder/default.asp" , 1 ) = 0 OR StrComp( page , "http://myserver/myfolder/" , 1 ) = 0

Depending on what the URL returns based on your server. But if you are noticing that it returns default.asp in the header then remove the OR condition.

glenngv
08-29-2005, 04:12 PM
dim page
page = Request.ServerVariables("URL")
if StrComp("/default.asp", page, 1)<>0 then 'not in /default.asp
Response.write("<tr><td width=""100%"" height=""20""style=""padding:2px;"">HOME</td></tr>")
end if



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum