Use a literal as an HTML anchor string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arch Stanton

    Use a literal as an HTML anchor string

    I'm trying to parse longitude and latitude into an anchor address
    string. It seems to be a straightforward enough idea, but I just can't
    seem to make it work. I've tried parsing literals into the string like this:

    <a href="http://www.mysite.com/" & <asp:literal runat="server"
    id="MyLiteral" & "rest of address string">

    But this only passes the address up the first quote mark. I've also
    tried constructing the entire string and just putting it into the anchor
    tag like this:

    <a href=<asp:liter al runat="server" id="MyLiteral"

    I've tried a dozen different permutations of this idea but none of them
    work, and none of my usual trusty help forums seem to address this
    question. Is there a way to do this?

  • Mark Rae [MVP]

    #2
    Re: Use a literal as an HTML anchor string

    "Arch Stanton" <sade@hill.orgw rote in message
    news:fO6dnQ2y19 m03j3VnZ2dnUVZ_ hqdnZ2d@comcast .com...
    I've tried a dozen different permutations of this idea but none of them
    work, and none of my usual trusty help forums seem to address this
    question. Is there a way to do this?
    Firstly, is there a reason why you're not using the <asp:Hyperlin k />
    webcontrol?



    --
    Mark Rae
    ASP.NET MVP


    Comment

    • HillBilly

      #3
      Re: Use a literal as an HTML anchor string

      And what's the end result supposed to look like and why? There's a couple of
      options one of which Mark Rae suggested using the HyprLink control --but--
      circumstances usually determine how code is best written for whatever
      reasons provide some rationale. You could for example also bind the return
      value of a method for example...

      <a href='<%# ReturnLatLongUr l() %>'>Link Text</a>




      "Arch Stanton" <sade@hill.orgw rote in message
      news:fO6dnQ2y19 m03j3VnZ2dnUVZ_ hqdnZ2d@comcast .com...
      I'm trying to parse longitude and latitude into an anchor address string.
      It seems to be a straightforward enough idea, but I just can't seem to
      make it work. I've tried parsing literals into the string like this:
      >
      <a href="http://www.mysite.com/" & <asp:literal runat="server"
      id="MyLiteral" & "rest of address string">
      >
      But this only passes the address up the first quote mark. I've also tried
      constructing the entire string and just putting it into the anchor tag
      like this:
      >
      <a href=<asp:liter al runat="server" id="MyLiteral"
      >
      I've tried a dozen different permutations of this idea but none of them
      work, and none of my usual trusty help forums seem to address this
      question. Is there a way to do this?
      >

      Comment

      • Arch Stanton

        #4
        Re: Use a literal as an HTML anchor string


        Didn't know how to use the single quote (apostrophe) in that way. That
        made one of my solutions work. Thanks so much for taking time to reply.

        Grateful Noob :|



        HillBilly wrote:
        And what's the end result supposed to look like and why? There's a
        couple of options one of which Mark Rae suggested using the HyprLink
        control --but-- circumstances usually determine how code is best
        written for whatever reasons provide some rationale. You could for
        example also bind the return value of a method for example...
        >
        <a href='<%# ReturnLatLongUr l() %>'>Link Text</a>
        >
        >
        >
        >
        "Arch Stanton" <sade@hill.orgw rote in message
        news:fO6dnQ2y19 m03j3VnZ2dnUVZ_ hqdnZ2d@comcast .com...
        >I'm trying to parse longitude and latitude into an anchor address
        >string. It seems to be a straightforward enough idea, but I just can't
        >seem to make it work. I've tried parsing literals into the string like
        >this:
        >>
        ><a href="http://www.mysite.com/" & <asp:literal runat="server"
        >id="MyLiteral" & "rest of address string">
        >>
        >But this only passes the address up the first quote mark. I've also
        >tried constructing the entire string and just putting it into the
        >anchor tag like this:
        >>
        ><a href=<asp:liter al runat="server" id="MyLiteral"
        >>
        >I've tried a dozen different permutations of this idea but none of
        >them work, and none of my usual trusty help forums seem to address
        >this question. Is there a way to do this?
        >>
        >

        Comment

        • Arch Stanton

          #5
          Re: Use a literal as an HTML anchor string


          Truth is I haven't educated myself on that web control yet, but I will
          now. I solved my problem another way, but thanks very much for taking
          the time to reply.

          Grateful Noob :|



          Mark Rae [MVP] wrote:
          "Arch Stanton" <sade@hill.orgw rote in message
          news:fO6dnQ2y19 m03j3VnZ2dnUVZ_ hqdnZ2d@comcast .com...
          >
          >I've tried a dozen different permutations of this idea but none of
          >them work, and none of my usual trusty help forums seem to address
          >this question. Is there a way to do this?
          >
          Firstly, is there a reason why you're not using the <asp:Hyperlin k />
          webcontrol?

          >
          >
          >

          Comment

          • HillBilly

            #6
            Re: Use a literal as an HTML anchor string

            Single quoted attributes are supported in HTML and help avoid errors when
            other server-side code is being used requires using the double quote such as
            this example:

            // error
            <a href="<%# Eval(Container. DataItem, "StringValu e") %>">Link Text</a>

            // no error
            <a href='<%# Eval(Container. DataItem, "StringValu e") %>'>Link Text</a>



            "Arch Stanton" <sade@hill.orgw rote in message
            news:nJmdnU_gdf pZYz3VnZ2dnUVZ_ jCdnZ2d@comcast .com...
            >
            Didn't know how to use the single quote (apostrophe) in that way. That
            made one of my solutions work. Thanks so much for taking time to reply.
            >
            Grateful Noob :|
            >
            >
            >
            HillBilly wrote:
            >And what's the end result supposed to look like and why? There's a couple
            >of options one of which Mark Rae suggested using the HyprLink
            >control --but-- circumstances usually determine how code is best written
            >for whatever reasons provide some rationale. You could for example also
            >bind the return value of a method for example...
            >>
            ><a href='<%# ReturnLatLongUr l() %>'>Link Text</a>
            >>
            >>
            >>
            >>
            >"Arch Stanton" <sade@hill.orgw rote in message
            >news:fO6dnQ2y1 9m03j3VnZ2dnUVZ _hqdnZ2d@comcas t.com...
            >>I'm trying to parse longitude and latitude into an anchor address
            >>string. It seems to be a straightforward enough idea, but I just can't
            >>seem to make it work. I've tried parsing literals into the string like
            >>this:
            >>>
            >><a href="http://www.mysite.com/" & <asp:literal runat="server"
            >>id="MyLiteral "& "rest of address string">
            >>>
            >>But this only passes the address up the first quote mark. I've also
            >>tried constructing the entire string and just putting it into the anchor
            >>tag like this:
            >>>
            >><a href=<asp:liter al runat="server" id="MyLiteral"
            >>>
            >>I've tried a dozen different permutations of this idea but none of them
            >>work, and none of my usual trusty help forums seem to address this
            >>question. Is there a way to do this?
            >>>
            >>

            Comment

            Working...