473,287 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Injecting Javascript in a User Control

149 100+
Hi,

I have a user control that will eventually dynamically embed a flash movie, but I can't get the basics to work.

I am using master pages then a home.aspx and then a user control.

Here's the code;

Expand|Select|Wrap|Line Numbers
  1. protected override void OnPreRender(EventArgs e) {
  2.                 base.OnPreRender(e);
  3.                 Page.ClientScript.RegisterClientScriptInclude(Parent.GetType(), "SWFobject.js", "_scripts/SWFobject.js");
  4.                 string scriptBlock =
  5.                 "<script type=\"text/javascript\" language=\"JavaScript\">" +
  6.                 "var fo = new SWFObject(\"_asset/flash/home.swf\", \"\", \"480\", \"296\", \"6\", \"#FFFFFF\");" +
  7.                 "fo.write(\"flashcontent\");" +
  8.                 "</script>";
  9.                 Page.ClientScript.RegisterClientScriptBlock(Parent.GetType(), "flashcontent", scriptBlock);
  10.         }
In the user control I have <div id="flashcontent">.

But I get a null error in IE?

Any help would be appreciated.
Jul 15 '07 #1
3 1323
rsdev
149 100+
I solved one issue!

If I wrap the div flashcontent in a body tag and then put onload and call the javascript as a function it works!

But it means in the code there are two body tags?!

Is there another way to do this?
Jul 15 '07 #2
rsdev
149 100+
I found the solution.

window.onload = function... in the javascript.

:)
Jul 15 '07 #3
kenobewan
4,871 Expert 4TB
Well done, thanks for sharing the solution :).
Jul 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
2
by: New User | last post by:
I have a System.Web.UI.UserControl as custom control and I have a javascript block for user control. The problem is I want to bring src attribute from outside as property or other method. e.g...
17
by: Luke Matuszewski | last post by:
Hi ! Simple question (but thus it may appear no simple answer): If i putting a script onto the page i simply could inline it in <script> element or via its src attribute so (second way): <script...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
14
by: ofiras | last post by:
Hii everyone, I'm a web programmer, but I never understood sql injecting. All I found was that you can write "a' or 'a'='a" in the password field to try to connect without knowing the password. I...
2
by: CrystalMikeMD | last post by:
Greetings, I've been at this problem for some time now and have decided to seek out some help. Essentially, this is what I have. A basic ASP.NET 2.0 page. On this page is the standard...
4
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user...
4
by: Andy B | last post by:
How do you add javascript to a page from codebehind? I have a method I am working on that has a few conditions in it: 1. if either 1 or both WordTextBox or DefinitionTextBox is empty, show a...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.