How to Rewrite url

Discussion in 'C#' started by dannbkk, Jun 20, 2007.

  1. #1
    I am a php programmer and I dont know much about ASP, but I would like to know one of my sites URL's hen clicked display this type of URL: location.asp?Location_ID=8 but instead I need it to display something like this location.asp?Location_ID=Thailand.

    Would that involve playing around with the htaccess file? I forgot ASP dont use htaccess files am i correct?
     
    dannbkk, Jun 20, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    no because you are passing it via querystring. You would just do a search on Thailand vs. an integer as the ID.
     
    ccoonen, Jun 20, 2007 IP
  3. dannbkk

    dannbkk Well-Known Member

    Messages:
    1,403
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Ah I see....... so any other suggestions? I mean I couldnt change the ID table in the database to different table name like ID=1 to Title=Thailand etc. could I?
     
    dannbkk, Jun 21, 2007 IP
  4. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can keep ID=1 and add a column Title=Thailand, then pull field Title from your DB instead of ID.
     
    50plus, Jun 21, 2007 IP
  5. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    yes, so you are using a search key instead of an integer as your conditional.

    instead of Select * from Table Where Table.IDField = 1

    you would o

    Select * from Table Where Table.LocationName = 'Thailand'
     
    ccoonen, Jun 22, 2007 IP
  6. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can use either one :
    Select * from Table Where Table.IDField = 1
    or
    Select * from Table Where Table.LocationName = 'Thailand'

    But when you complete your URL for location.asp?Location_ID=Thailand replace
    location.asp?Location_ID=<%=ID%> with
    location.asp?Location_ID=<%=Title%>

    (Title or whatever you have called the column)
     
    50plus, Jun 23, 2007 IP