Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > add onload to <body id="bodyId" runat="server"> using C#?

Reply
Thread Tools

add onload to <body id="bodyId" runat="server"> using C#?

 
 
Les Caudle
Guest
Posts: n/a
 
      11-19-2009
I've got a Master Page with <body id="bodyId" runat="server">

From one of the pages that uses the master page, I need to be able to add an
onload to the body tag.

I saw one suggestion for

-------------
1. Give the <body> tag an id, and make it run as a htmlcontrol

<body id="myBody" runat="server">

2. In your code-behind, create a reference to the body object, and attach the
function you need to the "onload" event.

Protected WithEvents myBody As
System.Web.UI.HtmlControls.HtmlContainerControl

body.Attributes("onload") = "myjavascriptfunction();"
----------------------

Which seems to partially have the right idea, but of course I need C#.

What's the best way to do this?

My goal is to add a small javascript routine that when it detects a <blink> tag,
will flash it on and off at an interval.

The interval is set in the body tag html for my other sites, but I'm having
trouble getting it to work for a site that uses Master pages.

I've tried using
Page.ClientScript.RegisterClientScriptBlock
to register the coe that is called, and then
Page.ClientScript.RegisterStartupScript
to register the initial call that sets the interval, but so far, it isn't
working.
--
Thanks in advance, Les Caudle
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
onload -->* no onload marco Javascript 7 06-24-2006 08:39 PM
Why doesn't frameset onload event get called when each of the frames has an onload? adnanx82@gmail.com Javascript 5 05-15-2005 01:58 PM
base.OnLoad called, OnLoad not executed Fabio R. ASP .Net 0 03-25-2005 01:21 PM
window.onload and body.onload differences David Otton Javascript 2 11-04-2004 04:34 PM
Add two onload links to a php page? Ohmster HTML 4 09-25-2004 05:30 PM



Advertisments