Set href for <link tag

Discussion in 'ASP .Net' started by Robert Strickland, Aug 25, 2004.

  1. I need to dynamically set the href attribute for the <link> tag at run time
    for my pages. I thought I saw code using the asp:placeholder to give the
    code-behind a place to update the html control with a specific href setting.

    Any ideas?

    Thanks
    Robert Strickland, Aug 25, 2004
    #1
    1. Advertising

  2. This sets technique sets the Title programmatically but you might be able to
    rejig it to do a <link>

    http://authors.aspalliance.com/kenc/faq5.aspx

    "Robert Strickland" <> wrote in message
    news:...
    >I need to dynamically set the href attribute for the <link> tag at run time
    > for my pages. I thought I saw code using the asp:placeholder to give the
    > code-behind a place to update the html control with a specific href
    > setting.
    >
    > Any ideas?
    >
    > Thanks
    >
    >
    Ken Cox [Microsoft MVP], Aug 25, 2004
    #2
    1. Advertising

  3. Robert Strickland

    Shiva Guest

    Hi,
    Give the <link> tag id="lnk" (can be anything) and runat=server attributes.
    From code-behind, use the Attributes property, like normal server-side
    controls, to add attribute values:

    lnk.Attributes.Add ("rel", "stylesheet")
    lnk.Attributes.Add ("href", "primary.css")

    HTH.

    "Robert Strickland" <> wrote in message
    news:...
    I need to dynamically set the href attribute for the <link> tag at run time
    for my pages. I thought I saw code using the asp:placeholder to give the
    code-behind a place to update the html control with a specific href setting.

    Any ideas?

    Thanks
    Shiva, Aug 25, 2004
    #3
  4. Thanks

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:#...
    > This sets technique sets the Title programmatically but you might be able

    to
    > rejig it to do a <link>
    >
    > http://authors.aspalliance.com/kenc/faq5.aspx
    >
    > "Robert Strickland" <> wrote in message
    > news:...
    > >I need to dynamically set the href attribute for the <link> tag at run

    time
    > > for my pages. I thought I saw code using the asp:placeholder to give the
    > > code-behind a place to update the html control with a specific href
    > > setting.
    > >
    > > Any ideas?
    > >
    > > Thanks
    > >
    > >

    >
    Robert Strickland, Aug 25, 2004
    #4
  5. thanks

    "Shiva" <> wrote in message
    news:#...
    > Hi,
    > Give the <link> tag id="lnk" (can be anything) and runat=server

    attributes.
    > From code-behind, use the Attributes property, like normal server-side
    > controls, to add attribute values:
    >
    > lnk.Attributes.Add ("rel", "stylesheet")
    > lnk.Attributes.Add ("href", "primary.css")
    >
    > HTH.
    >
    > "Robert Strickland" <> wrote in message
    > news:...
    > I need to dynamically set the href attribute for the <link> tag at run

    time
    > for my pages. I thought I saw code using the asp:placeholder to give the
    > code-behind a place to update the html control with a specific href

    setting.
    >
    > Any ideas?
    >
    > Thanks
    >
    >
    >
    Robert Strickland, Aug 25, 2004
    #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. Joel Leong
    Replies:
    0
    Views:
    622
    Joel Leong
    Feb 22, 2005
  2. shruds
    Replies:
    1
    Views:
    747
    John C. Bollinger
    Jan 27, 2006
  3. CRON
    Replies:
    24
    Views:
    200,428
    Adrienne Boswell
    Jun 20, 2006
  4. Soren Vejrum
    Replies:
    4
    Views:
    518
    Lasse Reichstein Nielsen
    Jul 5, 2003
  5. Replies:
    9
    Views:
    141
    Doug Gunnoe
    Dec 10, 2007
Loading...

Share This Page