Add attribute to Body

Discussion in 'ASP .Net' started by Roger, Feb 6, 2004.

  1. Roger

    Roger Guest

    How do I add an onload attribute to the body of webpage dynamically?
    Roger, Feb 6, 2004
    #1
    1. Advertising

  2. Roger

    Dan Guest

    Give the body tag an ID and Runat="server" property in your ASPX:

    <body id="bodyHomePage" Runat="Server">

    And then in your Page_Load do something like this:

    bodyHomePage.Attributes.Add("onLoad", "alert('Welcome visitor')")

    Dan


    "Roger" <> wrote in message
    news:...
    > How do I add an onload attribute to the body of webpage dynamically?
    >
    >
    Dan, Feb 6, 2004
    #2
    1. Advertising

  3. Roger

    Roger Guest

    thanks

    "Dan" <> wrote in message
    news:...
    > Give the body tag an ID and Runat="server" property in your ASPX:
    >
    > <body id="bodyHomePage" Runat="Server">
    >
    > And then in your Page_Load do something like this:
    >
    > bodyHomePage.Attributes.Add("onLoad", "alert('Welcome visitor')")
    >
    > Dan
    >
    >
    > "Roger" <> wrote in message
    > news:...
    > > How do I add an onload attribute to the body of webpage dynamically?
    > >
    > >

    >
    >
    Roger, Feb 6, 2004
    #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. Mark Rae

    Add an attribute to the tag <body>?

    Mark Rae, Oct 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    312
    Gustavo Arriola
    Oct 31, 2006
  2. John Kotuby

    Add body onload attribute from UserControl?

    John Kotuby, Apr 3, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    1,290
    Ben Rush
    Apr 5, 2007
  3. _Who
    Replies:
    4
    Views:
    590
  4. London Boy
    Replies:
    2
    Views:
    318
    Keith Bowes
    Jan 12, 2004
  5. Replies:
    5
    Views:
    200
    A. Sinan Unur
    Sep 8, 2005
Loading...

Share This Page