#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Hyperlink a Row in ASP


    Ok guys n gals, I have a wonderful document control site built in ASP, and I may say, most of my expertise was from the excellent forum we have here. The only thing I wish to do on my site to complete it is to hyperlink to the file the data refers to?

    At the moment, I have a column that I could place some code to direct to the file, but my attempts have been, lets say, not how i wanted it to work. Maybe someone could help me with this code.

    Code:
    <td nowrap>&nbsp;<a href="<%=objRs("Loc")%>" & "<%=objRs("Field1")%>" & "<%=objRs("Field2")%>" & ".pdf">Document</a></td>
    The 'Loc' is the server path, the 'field1' is the folder name, the 'Field2' is the file name, but as the folder has a .doc and .pdf version, I only want the .pdf version so I added the '.pdf' to the code. Of course you guessed it, it doesn't work.

    The other option I was looking at is to hyperlink a complete row. I have a piece of code that when the mouse hovers over a row it changes the colour, maybe I could hyperlink a mouseclick to this pieace of code?

    Code:
    <%
    If (counter mod 2) > 0 Then Response.Write "bgcolor='#D7D7D7' id='row"&counter&"' "Response.Write "onMouseOver='row"&counter&".style.backgroundColor = ""#a6caf0"";'onMouseOut='row"&counter&".style.backgroundColor = ""#D7D7D7"";' >"
    Else
    Response.Write "bgcolor='#EBEBEB' id='row"&counter&"' "Response.Write "onMouseOver='row"&counter&".style.backgroundColor = ""#a6caf0"";'onMouseOut='row"&counter&".style.backgroundColor = ""#EBEBEB"";' >"
    End If
    %>
    Any help would be greatfully recieved.
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,534
    Rep Power
    1906
    You link is mssing the delimeter / between the path and filename.
    How does the link look like in the browse?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0
    I have placed the delimiter in the code but it still only opens the 'Loc' and doesn't get me to the file?

    Code:
    <td nowrap>&nbsp;<a href="<%=objRs("Loc")%>" & "/" & "<%=objRs("Field1")%>" & "/" & "<%=objRs("Field2")%>" & ".pdf">More</a></td>
    What am i doing wrong?
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,534
    Rep Power
    1906
    You mixing HTML with ASP code. the & is not in ASP code, because you use "short" method to echo and thereby close ASP for each field.
    Take a look at this:
    Code:
    <td nowrap>&nbsp;<a href="<%=objRs("Loc")%>/<%=objRs("Field1")%>/<%=objRs("Field2")%>.pdf">More</a></td>
    But when you say 'Loc' is the server path, how does this path looks like?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0
    Thanks MrFujin, I now see that I was mixing HTML and ASP. I have made the alterations and it works great. Thanks again for your help.

IMN logo majestic logo threadwatch logo seochat tools logo