Hello, I am attempting to use RegisterClientScriptBlock and it is not seeming to work. Can someone take a look at my code?

Here is my C# (which I have in my PageLoad)

var videoLoadScript = " var so = new SWFObject('player.swf','mpl','955',' 540','9');";

videoLoadScript += "so.addParam('allowscriptaccess','always');";

videoLoadScript += "so.addParam('allowfullscreen','true');";

videoLoadScript += "so.addParam('flashvars','&file='" + path + "'&autostart=true');";

videoLoadScript += "so.write('player');";

ClientScript.RegisterClientScriptBlock(this.GetType(), "test", videoLoadScript, true);

Here is my HTML (which I have in my BODY tag):

<div id="player" oninit="test();" align="center">This text will be replaced</div>

does anyone see anything obviously wrong?

Hello,

I'm guessing that you have this C# in your code-behind file correct? If so, this is what I would write instead...

//all code up to the RegisterClientScriptBlock call is ok...
//Call the RegisterStartupScript method instead, it has the same signature as the
//RegisterClientScriptBlock method.
ClientScript.RegisterStartupScript(this.GetType(), "test", videoLoadScript, true);

Hope this helps...

That was my thought as well, but RegisterStartupScript gave me the same result :(

I had an extra tick mark in my function, thanks for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.