Trimming filename and paramters from a URL (output from DB)

Discussion in 'ASP General' started by Simon, Oct 28, 2004.

  1. Simon

    Simon Guest

    Hi there.

    I seem to be a flurry of questions here recently, thanks for you help all,
    but ... got another question here.

    I am storing URL in a database for a 'sort of' directory type website.

    The <a href> is built from the recordset of URL's which is all working no
    problem, easy stuff.

    What I have found is going to be necessary in some cases is to trim the URL
    back to just it's www.abc.co.uk address for the link display.

    I still want the actual link to go to it's long 'deep linking' location, but
    there is limited room for displaying a URL that could be a hundred chars
    long.

    So... Just to recap.

    www.abc.co.uk/products.asp?cat=1&id=234&somethingelse=12

    gets trimmed back to

    www.abc.co.uk

    Thanks in advance.

    Simon.
     
    Simon, Oct 28, 2004
    #1
    1. Advertising

  2. Simon

    Simon Guest

    I got ;-)

    I realised I was trimming the http:// from the inputted URL, so I only had
    to search for the first / and stop there.

    <%

    if not rs("URL")="" then

    iURL = instr(rs("URL"), "/")
    if iURL then tURL = left(rs("URL"), iURL-1) else tURL = rs("URL")
    fURL = tURL


    %><strong>Website</strong> : <a href="http://<%= rs("URL") %>"
    title="<%= fURL %>"><%= fURL %></a><br /><% end if %>

    Take care

    Si


    "Simon" <> wrote in message
    news:xo9gd.167513$...
    > Hi there.
    >
    > I seem to be a flurry of questions here recently, thanks for you help all,
    > but ... got another question here.
    >
    > I am storing URL in a database for a 'sort of' directory type website.
    >
    > The <a href> is built from the recordset of URL's which is all working no
    > problem, easy stuff.
    >
    > What I have found is going to be necessary in some cases is to trim the

    URL
    > back to just it's www.abc.co.uk address for the link display.
    >
    > I still want the actual link to go to it's long 'deep linking' location,

    but
    > there is limited room for displaying a URL that could be a hundred chars
    > long.
    >
    > So... Just to recap.
    >
    > www.abc.co.uk/products.asp?cat=1&id=234&somethingelse=12
    >
    > gets trimmed back to
    >
    > www.abc.co.uk
    >
    > Thanks in advance.
    >
    > Simon.
    >
    >
     
    Simon, Oct 28, 2004
    #2
    1. Advertising

  3. Simon

    Evertjan. Guest

    Simon wrote on 28 okt 2004 in microsoft.public.inetserver.asp.general:
    > trimming the http:// from the inputted URL



    fURL = replace(rs("URL"),"http://","/")

    or

    fURL = replace(rs("URL"),"http:/","")

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Oct 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXM=?=

    Help trimming URL path

    =?Utf-8?B?Q2hyaXM=?=, Dec 14, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,050
    Juan T. Llibre [MVP]
    Dec 14, 2004
  2. Bob Hanson
    Replies:
    2
    Views:
    845
    Steve C. Orr [MVP, MCSD]
    Mar 2, 2005
  3. LehrSJ

    Gridview Stored Procedure output paramters or return value

    LehrSJ, Dec 20, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    218
    Steven Cheng[MSFT]
    Dec 21, 2005
  4. J.Marsch

    Web Service with complex paramters and return types

    J.Marsch, Nov 14, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    125
  5. Diarmaid
    Replies:
    3
    Views:
    186
    Evertjan.
    May 12, 2004
Loading...

Share This Page