Thursday, March 22, 2012
Set href for <link tag
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?
ThanksThis 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" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
>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
>
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" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
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
thanks
"Shiva" <shiva_sm@.online.excite.com> wrote in message
news:#SjXjlliEHA.356@.tk2msftngp13.phx.gbl...
> 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" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> 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
>
>
Thanks
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:#TdPDLliEHA.636@.TK2MSFTNGP12.phx.gbl...
> 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" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
time
>
Set href for <link tag
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?
ThanksThis 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" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
>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
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" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
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
Thanks
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:#TdPDLliEHA.636@.TK2MSFTNGP12.phx.gbl...
> 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" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> >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
thanks
"Shiva" <shiva_sm@.online.excite.com> wrote in message
news:#SjXjlliEHA.356@.tk2msftngp13.phx.gbl...
> 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" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> 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
Set HTML Attribute In Page_Load Event
Page_Load event. I can't see how to do this. The main problem is that I
can't see how to access the HTML object from this event. Can anyone help ?
BenBen,
Forthe element you need to specify runat=server and id=myHtml. Then VS will
define the element for you in code-behind as the page's protected member. In
any page method you can set an attribute as (c# syntax):
myHtml.Attributes["myAttribute"]="my string";
Eliyahu
"Ben Foster" <ben.foster@.nospam.com> wrote in message
news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
> I want to be able to set an attribute of the HTML object in the form's
> Page_Load event. I can't see how to do this. The main problem is that I
> can't see how to access the HTML object from this event. Can anyone help ?
> Ben
Eliyahu,
That works fine. Thanks.
Ben
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:%23TIxNYBGFHA.3244@.TK2MSFTNGP15.phx.gbl...
> Ben,
> Forthe element you need to specify runat=server and id=myHtml. Then VS
> will
> define the element for you in code-behind as the page's protected member.
> In
> any page method you can set an attribute as (c# syntax):
> myHtml.Attributes["myAttribute"]="my string";
> Eliyahu
> "Ben Foster" <ben.foster@.nospam.com> wrote in message
> news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
>> I want to be able to set an attribute of the HTML object in the form's
>> Page_Load event. I can't see how to do this. The main problem is that I
>> can't see how to access the HTML object from this event. Can anyone help
>> ?
>>
>> Ben
>>
>>
Set HTML Attribute In Page_Load Event
Page_Load event. I can't see how to do this. The main problem is that I
can't see how to access the HTML object from this event. Can anyone help ?
BenBen,
Forthe element you need to specify runat=server and id=myHtml. Then VS will
define the element for you in code-behind as the page's protected member. In
any page method you can set an attribute as (c# syntax):
myHtml.Attributes["myAttribute"]="my string";
Eliyahu
"Ben Foster" <ben.foster@.nospam.com> wrote in message
news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
> I want to be able to set an attribute of the HTML object in the form's
> Page_Load event. I can't see how to do this. The main problem is that I
> can't see how to access the HTML object from this event. Can anyone help ?
> Ben
>
Eliyahu,
That works fine. Thanks.
Ben
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:%23TIxNYBGFHA.3244@.TK2MSFTNGP15.phx.gbl...
> Ben,
> Forthe element you need to specify runat=server and id=myHtml. Then VS
> will
> define the element for you in code-behind as the page's protected member.
> In
> any page method you can set an attribute as (c# syntax):
> myHtml.Attributes["myAttribute"]="my string";
> Eliyahu
> "Ben Foster" <ben.foster@.nospam.com> wrote in message
> news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
>