Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0javascript onload eventjavascript onload event
Previous
 
Next
New Post
7/26/2007 9:35 AM
 

Hi

In my 3.x modules i added an onload event to the body tag to run some javascript which use to work fine. This doesn't seem to work with later version of DNN. Does anyone know why. the attribute is added to the body tag it just doesn't run.

Dim

hgcBody As System.Web.UI.HtmlControls.HtmlGenericControl = Page.FindControl("Body")If Not hgcBody Is Nothing Then

hgcBody.Attributes.Add(

 

"onload", "display()")End If

Cheers

 

 
New Post
7/26/2007 1:13 PM
 

Corrections the event fires in opera, but not ie or firefox.

Really frustrating.

any ideas??

 
New Post
7/27/2007 5:07 AM
 

Hi, just in case some one has the same problem i found an alternative that works, which doesn't consist of adding anything into the body tag

basically below. Didn't know you could use the onload event like this. *shurgs* 

Dim

strStartScript As String = "<script language=""javascript"" type=""text/javascript"">onload=function(){ DoYourStuff(); }</script>"

Page.ClientScript.RegisterStartupScript(

Me.GetType(), "StartUp", strStartScript)

 
New Post
7/30/2007 6:04 PM
 

You want to be careful simply replacing the onload event, as other controls or even DNN itself may have its own function registered.  It is recommended using the AddBodyOnLoadEventHandler method. 

Page 6 of this document explains a little more.


 
New Post
8/1/2007 9:10 AM
 

Hi Jon

Thanks for the pointer.  I found the document a little confusing as i saw no AddBodyOnloadEventHandler method in the ClientAPI class, but in the DNNClientAPI under the same namespace.

So i simple added the following line:

DNNClientAPI.AddBodyOnloadEventHandler(Me.Parent.Page, "myfunction()")

And seems to work fine, is this how you saw the handler being used?

Thanks very much

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0javascript onload eventjavascript onload event


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out