Dynamically setting file name in a hyperlink

Discussion in 'ASP .Net Building Controls' started by Anne Butera, Nov 7, 2007.

  1. Anne Butera

    Anne Butera Guest

    I want to set a navigate URL to include the name of a file, that is derived
    from a field from the SQL query. I get "Server Tag is not well formed" when
    I try to run this:

    <asp:HyperLink ID="hyperlink" runat="server" NavigateUrl="\\server\share\"
    '<%# Eval("storeNumber")'%> ".doc" >config1</asp:HyperLink>

    I want the url to be \\server\share\3.doc

    Can someone please tell me what I am doing wrong, or is there a better way
    to do this?

    Thank you for your time

    Ann
     
    Anne Butera, Nov 7, 2007
    #1
    1. Advertising

  2. Ann,

    If you look at the NavigateUrl attribute, you have a bunch of single and
    doublequotes. You're going to end up with somethign that looks like this

    \\server\share"'3".doc"

    Try something like this
    <asp:HyperLink ID="hyperlink" runat="server"
    NavigateUrl="\\server\share\<%# Eval("storeNumber")%>.doc"
    >config1</asp:HyperLink>



    --

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Expression

    "Anne Butera" <> wrote in message
    news:D...
    >I want to set a navigate URL to include the name of a file, that is derived
    > from a field from the SQL query. I get "Server Tag is not well formed"
    > when
    > I try to run this:
    >
    > <asp:HyperLink ID="hyperlink" runat="server" NavigateUrl="\\server\share\"
    > '<%# Eval("storeNumber")'%> ".doc" >config1</asp:HyperLink>
    >
    > I want the url to be \\server\share\3.doc
    >
    > Can someone please tell me what I am doing wrong, or is there a better way
    > to do this?
    >
    > Thank you for your time
    >
    > Ann
     
    Mark Fitzpatrick, Nov 7, 2007
    #2
    1. Advertising

  3. Anne Butera

    Anne Butera Guest

    Thank you for your reply.

    So I tried your suggetions, and now I'm able to run the form and click the
    hyperlink, but the url looks like this:

    \\server\share\<%# Eval("storeNumber") %>.doc

    Here's the code I used:

    <asp:HyperLink ID="HLconfig1" runat="server" NavigateUrl='\\server\share\<%#
    Eval("storeNumber") %>.doc'>config1</asp:HyperLink>


    Do you have any other suggestions? Thank you for your time.


    "Mark Fitzpatrick" wrote:

    > Ann,
    >
    > If you look at the NavigateUrl attribute, you have a bunch of single and
    > doublequotes. You're going to end up with somethign that looks like this
    >
    > \\server\share"'3".doc"
    >
    > Try something like this
    > <asp:HyperLink ID="hyperlink" runat="server"
    > NavigateUrl="\\server\share\<%# Eval("storeNumber")%>.doc"
    > >config1</asp:HyperLink>

    >
    >
    > --
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP - Expression
    >
    > "Anne Butera" <> wrote in message
    > news:D...
    > >I want to set a navigate URL to include the name of a file, that is derived
    > > from a field from the SQL query. I get "Server Tag is not well formed"
    > > when
    > > I try to run this:
    > >
    > > <asp:HyperLink ID="hyperlink" runat="server" NavigateUrl="\\server\share\"
    > > '<%# Eval("storeNumber")'%> ".doc" >config1</asp:HyperLink>
    > >
    > > I want the url to be \\server\share\3.doc
    > >
    > > Can someone please tell me what I am doing wrong, or is there a better way
    > > to do this?
    > >
    > > Thank you for your time
    > >
    > > Ann

    >
    >
    >
     
    Anne Butera, Nov 7, 2007
    #3
  4. Anne Butera

    Riki Guest

    Try:
    NavigateUrl='<%# Eval("storeNumber","\\server\share\{0}") %>'

    --
    Riki

    Anne Butera wrote:
    > Thank you for your reply.
    >
    > So I tried your suggetions, and now I'm able to run the form and
    > click the hyperlink, but the url looks like this:
    >
    > \\server\share\<%# Eval("storeNumber") %>.doc
    >
    > Here's the code I used:
    >
    > <asp:HyperLink ID="HLconfig1" runat="server"
    > NavigateUrl='\\server\share\<%# Eval("storeNumber")
    > %>.doc'>config1</asp:HyperLink>
    >
    >
    > Do you have any other suggestions? Thank you for your time.
    >
    >
    > "Mark Fitzpatrick" wrote:
    >
    >> Ann,
    >>
    >> If you look at the NavigateUrl attribute, you have a bunch of single
    >> and doublequotes. You're going to end up with somethign that looks
    >> like this
    >>
    >> \\server\share"'3".doc"
    >>
    >> Try something like this
    >> <asp:HyperLink ID="hyperlink" runat="server"
    >> NavigateUrl="\\server\share\<%# Eval("storeNumber")%>.doc"
    >> >config1</asp:HyperLink>

    >>
    >>
    >> --
    >>
    >> Hope this helps,
    >> Mark Fitzpatrick
    >> Microsoft MVP - Expression
    >>
    >> "Anne Butera" <> wrote in message
    >> news:D...
    >>> I want to set a navigate URL to include the name of a file, that is
    >>> derived from a field from the SQL query. I get "Server Tag is not
    >>> well formed" when
    >>> I try to run this:
    >>>
    >>> <asp:HyperLink ID="hyperlink" runat="server"
    >>> NavigateUrl="\\server\share\" '<%# Eval("storeNumber")'%> ".doc"
    >>> >config1</asp:HyperLink>
    >>>
    >>> I want the url to be \\server\share\3.doc
    >>>
    >>> Can someone please tell me what I am doing wrong, or is there a
    >>> better way to do this?
    >>>
    >>> Thank you for your time
    >>>
    >>> Ann
     
    Riki, Nov 11, 2007
    #4
  5. Anne Butera

    Anne Butera Guest

    Yes, that worked! Thanks

    "Riki" wrote:

    > Try:
    > NavigateUrl='<%# Eval("storeNumber","\\server\share\{0}") %>'
    >
    > --
    > Riki
    >
    > Anne Butera wrote:
    > > Thank you for your reply.
    > >
    > > So I tried your suggetions, and now I'm able to run the form and
    > > click the hyperlink, but the url looks like this:
    > >
    > > \\server\share\<%# Eval("storeNumber") %>.doc
    > >
    > > Here's the code I used:
    > >
    > > <asp:HyperLink ID="HLconfig1" runat="server"
    > > NavigateUrl='\\server\share\<%# Eval("storeNumber")
    > > %>.doc'>config1</asp:HyperLink>
    > >
    > >
    > > Do you have any other suggestions? Thank you for your time.
    > >
    > >
    > > "Mark Fitzpatrick" wrote:
    > >
    > >> Ann,
    > >>
    > >> If you look at the NavigateUrl attribute, you have a bunch of single
    > >> and doublequotes. You're going to end up with somethign that looks
    > >> like this
    > >>
    > >> \\server\share"'3".doc"
    > >>
    > >> Try something like this
    > >> <asp:HyperLink ID="hyperlink" runat="server"
    > >> NavigateUrl="\\server\share\<%# Eval("storeNumber")%>.doc"
    > >> >config1</asp:HyperLink>
    > >>
    > >>
    > >> --
    > >>
    > >> Hope this helps,
    > >> Mark Fitzpatrick
    > >> Microsoft MVP - Expression
    > >>
    > >> "Anne Butera" <> wrote in message
    > >> news:D...
    > >>> I want to set a navigate URL to include the name of a file, that is
    > >>> derived from a field from the SQL query. I get "Server Tag is not
    > >>> well formed" when
    > >>> I try to run this:
    > >>>
    > >>> <asp:HyperLink ID="hyperlink" runat="server"
    > >>> NavigateUrl="\\server\share\" '<%# Eval("storeNumber")'%> ".doc"
    > >>> >config1</asp:HyperLink>
    > >>>
    > >>> I want the url to be \\server\share\3.doc
    > >>>
    > >>> Can someone please tell me what I am doing wrong, or is there a
    > >>> better way to do this?
    > >>>
    > >>> Thank you for your time
    > >>>
    > >>> Ann

    >
    >
    >
     
    Anne Butera, Nov 13, 2007
    #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. =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=

    Getting dynamically web app name [or virtual dir name]

    =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=, Aug 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    767
    Craig Deelsnyder
    Aug 30, 2004
  2. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    863
    Roedy Green
    Jan 2, 2006
  3. davetichenor
    Replies:
    1
    Views:
    864
    Eliyahu Goldin
    Oct 30, 2006
  4. Ken
    Replies:
    1
    Views:
    397
    Alvin Bruney
    Aug 16, 2003
  5. Dave
    Replies:
    0
    Views:
    970
Loading...

Share This Page