Generate URL link for name with space between characters

Discussion in 'ASP General' started by uandme72, Mar 26, 2009.

  1. uandme72

    uandme72 Guest

    I want to generate url link with <a> </a> tags such that the href="abc def
    ghi" has space characters present in the link.

    However, I get only the first part of the file name as the link (abc from
    the above example) instead of the full
    name (abc def ghi).
    I tried server.htmlencode and server.urlencode but the link is not
    getting generated as expected.

    Kindly advise on how to get the url link of the full file name which has
    space in the name.

    uandme72
     
    uandme72, Mar 26, 2009
    #1
    1. Advertising

  2. uandme72 wrote on Thu, 26 Mar 2009 21:16:39 +0530:

    > I want to generate url link with <a> </a> tags such that the href="abc
    > def ghi" has space characters present in the link.


    > However, I get only the first part of the file name as the link (abc
    > from the above example) instead of the full name (abc def ghi).
    > I tried server.htmlencode and server.urlencode but the link is not
    > getting generated as expected.


    > Kindly advise on how to get the url link of the full file name which
    > has space in the name.


    > uandme72



    Filenames with spaces need to be passed in URLs with %20 replacing the
    spaces. Neither Server.HTMLEncode nor Server.URLEncode will do this -
    HTMLEncode is used for encoding text to be used in HTML (and space are valid
    HTML characters), and URLEncode is for encoding querystring/post field name
    and values.

    eg.

    <%
    the_link_filename = "my file.htm"
    %>

    <a href="<%=Replace(the_link_filename," ","%20")%>">text</a>


    --
    Dan
     
    Daniel Crichton, Mar 26, 2009
    #2
    1. Advertising

  3. uandme72

    uandme72 Guest

    "Daniel Crichton" <> wrote in message
    news:...
    > uandme72 wrote on Thu, 26 Mar 2009 21:16:39 +0530:
    >
    >> I want to generate url link with <a> </a> tags such that the href="abc
    >> def ghi" has space characters present in the link.

    >
    >> However, I get only the first part of the file name as the link (abc
    >> from the above example) instead of the full name (abc def ghi).
    >> I tried server.htmlencode and server.urlencode but the link is not
    >> getting generated as expected.

    >
    >> Kindly advise on how to get the url link of the full file name which
    >> has space in the name.

    >
    >> uandme72

    >
    >
    > Filenames with spaces need to be passed in URLs with %20 replacing the
    > spaces. Neither Server.HTMLEncode nor Server.URLEncode will do this -
    > HTMLEncode is used for encoding text to be used in HTML (and space are
    > valid HTML characters), and URLEncode is for encoding querystring/post
    > field name and values.


    Apart from space characters, are there any other special characters for
    which we need to plan beforehand and insert code for replacing them as
    indicated for the space characters above.







    >
    > eg.
    >
    > <%
    > the_link_filename = "my file.htm"
    > %>
    >
    > <a href="<%=Replace(the_link_filename," ","%20")%>">text</a>
    >
    >
    > --
    > Dan
    >
    >
     
    uandme72, Mar 26, 2009
    #3
  4. Gazing into my crystal ball I observed "uandme72" <>
    writing in news::

    >
    > "Daniel Crichton" <> wrote in message
    > news:...
    >> uandme72 wrote on Thu, 26 Mar 2009 21:16:39 +0530:
    >>
    >>> I want to generate url link with <a> </a> tags such that the

    href="abc
    >>> def ghi" has space characters present in the link.

    >>
    >>> However, I get only the first part of the file name as the link (abc
    >>> from the above example) instead of the full name (abc def ghi).
    >>> I tried server.htmlencode and server.urlencode but the link is not
    >>> getting generated as expected.

    >>
    >>> Kindly advise on how to get the url link of the full file name which
    >>> has space in the name.

    >>
    >>> uandme72

    >>
    >>
    >> Filenames with spaces need to be passed in URLs with %20 replacing

    the
    >> spaces. Neither Server.HTMLEncode nor Server.URLEncode will do this -
    >> HTMLEncode is used for encoding text to be used in HTML (and space

    are
    >> valid HTML characters), and URLEncode is for encoding

    querystring/post
    >> field name and values.

    >
    > Apart from space characters, are there any other special characters

    for
    > which we need to plan beforehand and insert code for replacing them as
    > indicated for the space characters above.
    >


    I try to stay away from anything that is not a alphabetic character or a
    number, with the exception of underline
    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Mar 27, 2009
    #4
  5. uandme72 wrote on Fri, 27 Mar 2009 00:06:41 +0530:


    > "Daniel Crichton" <> wrote in message news:...
    >> uandme72 wrote on Thu, 26 Mar 2009 21:16:39 +0530:


    >>> I want to generate url link with <a> </a> tags such that the
    >>> href="abc def ghi" has space characters present in the link.


    >>> However, I get only the first part of the file name as the link (abc
    >>> from the above example) instead of the full name (abc def ghi).
    >>> I tried server.htmlencode and server.urlencode but the link is not
    >>> getting generated as expected.


    >>> Kindly advise on how to get the url link of the full file name which
    >>> has space in the name.


    >>> uandme72



    >> Filenames with spaces need to be passed in URLs with %20 replacing
    >> the spaces. Neither Server.HTMLEncode nor Server.URLEncode will do
    >> this -
    >> HTMLEncode is used for encoding text to be used in HTML (and space
    >> are valid HTML characters), and URLEncode is for encoding
    >> querystring/post field name and values.


    > Apart from space characters, are there any other special characters for
    > which we need to plan beforehand and insert code for replacing them as
    > indicated for the space characters above.



    Yes. Anything in a filename which is part of the URL specification, eg. & ?
    # ; / and likely a few more besides. Personally I never use anything other
    than letters, numbers, hyphens, and underscores in filenames due to the
    problems anything else can cause.

    --
    Dan
     
    Daniel Crichton, Mar 27, 2009
    #5
    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. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,977
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,798
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,105
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    783
    Michael Hudson
    Oct 24, 2003
  5. =?Utf-8?B?ZHc=?=
    Replies:
    5
    Views:
    1,147
    Alan Silver
    Jul 30, 2006
Loading...

Share This Page