473,321 Members | 1,916 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,321 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 1325
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.