Accessing an embedded UserControl "<object" in javascript

Discussion in 'ASP .Net Web Controls' started by Mombiatch, Jul 28, 2004.

  1. Mombiatch

    Mombiatch Guest

    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
     
    Mombiatch, Jul 28, 2004
    #1
    1. Advertising

  2. Mombiatch

    Mombiatch Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
     
    Mombiatch, Jul 30, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phl
    Replies:
    2
    Views:
    543
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=
    Nov 18, 2004
  2. Replies:
    2
    Views:
    3,934
  3. Damon Getsman
    Replies:
    3
    Views:
    716
    Nigel Wade
    Sep 24, 2008
  4. protic
    Replies:
    0
    Views:
    362
    protic
    Oct 15, 2008
  5. Fabrizio

    accessing label in usercontrol from javascript

    Fabrizio, Feb 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    154
    Fabrizio
    Feb 27, 2004
Loading...

Share This Page