Thursday, March 22, 2012

Set HTML Attribute In Page_Load Event

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 ?

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
>>
>>

0 comments:

Post a Comment