Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    show / hide text

    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:
    Code:
    <% 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,

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    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
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/ ??

  • #4
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    StrComp( page , "http://myserver/myfolder/" , 1 ) = 0
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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:

    Code:
    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
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SpirtOfGrandeur
    StrComp( page , "http://myserver/myfolder/" , 1 ) = 0
    Code:
    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.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    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
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •