PC Review


Reply
Thread Tools Rate Thread

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

 
 
Les Caudle
Guest
Posts: n/a
 
      19th Nov 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
Rate This Thread
Rate This Thread:

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
placing runat="server" in body tag causes discrepancies with loadi =?Utf-8?B?d3d3LnJlZ29ubGluZS5jb20=?= Microsoft Dot NET Framework 1 9th Nov 2004 09:46 PM
<INPUT type="file" runat="server" - attach to email =?Utf-8?B?U2liQW5kZWxh?= Microsoft ASP .NET 1 2nd Aug 2004 02:53 AM
<input id="iPhoto" type="file" size="20" runat="server"> Mark Sandfox Microsoft ASP .NET 1 11th May 2004 02:58 AM
Re: <tr id="MyRow" runat="server"> ... </tr> doesn't appear in server-side code Marina Microsoft ASP .NET 0 21st Jul 2003 03:34 PM
Re: <tr id="MyRow" runat="server"> ... </tr> doesn't appear in server-side code Elliot M. Rodriguez Microsoft ASP .NET 0 21st Jul 2003 03:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:55 AM.