Set HTML Attribute In Page_Load Event

Discussion in 'ASP .Net' started by Ben Foster, Feb 21, 2005.

  1. Ben Foster

    Ben Foster Guest

    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
    Ben Foster, Feb 21, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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 Goldin, Feb 21, 2005
    #2
    1. Advertising

  3. Ben Foster

    Ben Foster Guest

    Eliyahu,

    That works fine. Thanks.

    Ben

    "Eliyahu Goldin" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    >> 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
    >>
    >>

    >
    >
    Ben Foster, Feb 21, 2005
    #3
    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. bminder
    Replies:
    1
    Views:
    2,162
    nfedin
    Feb 23, 2004
  2. Frank L
    Replies:
    0
    Views:
    411
    Frank L
    Mar 4, 2004
  3. z. f.
    Replies:
    0
    Views:
    557
    z. f.
    Oct 19, 2004
  4. Jimmy
    Replies:
    5
    Views:
    15,274
    =?Utf-8?B?Sm9yZ2UgTCBNYXRvcyBbTUNTRC5ORVRd?=
    Apr 27, 2005
  5. rockdale
    Replies:
    1
    Views:
    655
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
Loading...

Share This Page