Accessing an embedded UserControl "<object" in javascript

M

Mombiatch

Hi

I'm trying to set a property on a UserControl that I've embedded in my
ASP.NET web page. At first, I had the following in the <form> section:

<object id="mediaclient"
classid="mediaclient.dll#NeuralFramework.MediaBroker.MediaClient"></object>

When I tried to use custom javascript to set a property on 'mediaclient', I
put the following in Page_Load:

this.RegisterStartupScript("setGUID", "<script
language=javascript>mediaclient.strFileGUID=\"6a35ba9b-bbde-4678-9057-fb15c7
a685b8\";var gControl = mediaclient;alert(gControl.strFileGuid);</script>");

With the object in the form section, this bombs out saying that mediaclient
is null. So I tried putting it in the <body> section, before the <form>
section, and this works nicely, I can set the property and then use it when
I call functions of the UserControl. I then tried to put it after the <form>
section, but still in the <body> section, as I'd like it to be on the bottom
of the page. Unfortunately, it bombed out there too, saying that mediaclient
was once again null. Does anyone have any advice on getting around this or a
different strategy to suggest?

Thanks
Joe
 
M

Mombiatch

I have the solution to this problem, right in my office :p One embeds it in
the form section, and then any JavaScript calls are made with the name
qualified with the form's id, like Form1.mediaclient.strFileGuid.

Joe

Mombiatch said:
Hi

I'm trying to set a property on a UserControl that I've embedded in my
ASP.NET web page. At first, I had the following in the <form> section:

<object id="mediaclient"
classid="mediaclient.dll#NeuralFramework.MediaBroker.MediaClient"> said:
When I tried to use custom javascript to set a property on 'mediaclient', I
put the following in Page_Load:

this.RegisterStartupScript("setGUID", "<script
language=javascript>mediaclient.strFileGUID=\"6a35ba9b-bbde-4678-9057-fb15c7
a685b8\";var gControl =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,083
Latest member
SylviaHarr

Latest Threads

Top