Accessing Managed Code From HTMLPlaceHolder Control

17 posts, 0 answers
  1. Dave
    Dave avatar
    26 posts
    Member since:
    Jun 2009

    Posted 06 Sep 2009 Link to this post

    I am trying to call manage code from the Javascript  within HTMLPlaceHolder control.  I am trying to follow the example from http://msdn.microsoft.com/en-us/library/cc221414(VS.95).aspx. I can't seem to get a reference to the host Silverlight Control.  Am I missing how to do this?

    Thanks
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 07 Sep 2009 Link to this post

    Hello Dave,

    This should not be a problem. How you are executin the Javascript code? Is the code executed at all?

    Kind regards,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Dave
    Dave avatar
    26 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    Yes the Javascript code from with in my HTMLPlaceHolder is getting called.  It just can't find a reference to the host Silverlight control to make the managed call.  In fact the Javascript in the HTMLPlaceHolder can't reference any Javascript on the host page.   Do you have an example of Javascript within the HTMLPlaceHolder calling managed code?

    Thanks.
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 08 Sep 2009 Link to this post

    Hello Dave,

    Are you using the the html placeholder with inline content (using the HtmlSource property) or are you refering external page (by using the SourceUri property)?

    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Dave
    Dave avatar
    26 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    I am using the SourceUrl property of the HTMLPlaceHolder Control to set the uri. 
  7. Dave
    Dave avatar
    26 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    Is there any additional information on this topic?

    Thanks 
  8. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 09 Sep 2009 Link to this post

    Hello Dave,

    The reason why you can't get the Silverlight object is that your code is in different HTML page which do not "know" about the Silverlight application. You need to write a logic in your external page in order to get the Silverlight application.

    I've prepared a simple project where this is implemented. Please let us know if you need any clarification,

    Kind regards,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Dave
    Dave avatar
    26 posts
    Member since:
    Jun 2009

    Posted 09 Sep 2009 Link to this post

    That looks like what I need.  Thanks!

  10. Srinivas
    Srinivas avatar
    48 posts
    Member since:
    May 2009

    Posted 09 Sep 2009 Link to this post

    Hi,
    The example works wonderfully for me (Supplied Project)...

    I understand I need to put the code below at the TOP PAGE, which I did.

    My RADHTMLPlaceHolder is inside a TAB which is inside a pane.

    So, then I try

    var

     

    silverlightApplication = parent.GetSilverlightApplication();

    it was returning me a null pointer as parent is not the RootVisualTab.

     


    How do I get the pointer to RootVisualTab in the Javascript inside a RadHtmlPlaceHolder?

    ===== CODE FOLLOWS =====

     

    HtmlPage.RegisterScriptableObject("MySilverlightPage", this);

     

    }

    [

    ScriptableMember]

     

     

    public void HandleOutSideClick()

     

    {

    LayoutRoot.Background =

    new SolidColorBrush(Colors.Red);

     

    }

  11. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 10 Sep 2009 Link to this post

    Hello Srinivas,

    This code:

    var silverlightApplication = parent.GetSilverlightApplication(); 

    should stay in the html page - this is a javscript code - it is not supposed to be executed in the Silverlight application.

    Can you send us your project so we can modify it for you. Please send a support ticket with the project attached.

    All the best,
    Valentin.Stoychev
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. Srinivas
    Srinivas avatar
    48 posts
    Member since:
    May 2009

    Posted 14 Sep 2009 Link to this post

    I have fixed this issue. It had to do with me not setting the id of Silverlight control right.

    Thanks a lot.
  13. Jason
    Jason avatar
    9 posts
    Member since:
    Jul 2008

    Posted 13 Oct 2009 Link to this post

    I was unable to get this working by the setting the HTMLPlaceHolder's HtmlSource property. This seems to only work with the SourceUrl property--which is what was used in the example created by Valentin.

    Valentin, can you confirm this?
  14. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 13 Oct 2009 Link to this post

    Hello Jason,

    Yes - this example addresses the scenario where you use the HtmlPlaceholder with external page.

    The solution for the HtmlSoure will be different. Please let us know your specific problem to see if we can help.

    All the best,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Mitch Newlin
    Mitch Newlin avatar
    5 posts
    Member since:
    Sep 2009

    Posted 23 Nov 2010 Link to this post

    What do you do when the app is running out of browser?  Is there really no way for the RadHtmlPlaceholder to call managed code directly?
  16. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 26 Nov 2010 Link to this post

    Hi Mitch,

    RadHtmlPlaceholder is part of the Silverlight environment, so I don't see any reason it being unable to call managed code. However, calling JavaScript code is not allowed since OOB applications have no connection to the DOM.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  17. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 22 May 2013 Link to this post

    Sorry for bringing up an old thread...
    I need to access an external URL via an htmlPlaceholder. This works fine. I also need the external url to return a response to my silverlight application (send a string). This works fine using the sample in this thread (By registering a scriptable object and then register a ScriptableMember which intercepts a function call from the external web page with a string as parameter.)
    BUT, this seems to only work fine if the two web-sites sit in the same domain, but in my case, the external url is on a different server (Silverligt application on an IIS server, the other on an apache server)
    The apache web-page only get the error  "no access/permission" if it tries to call the event in the parent Silverlight application.

    Is there a way the htmlPlaceholder can handle communication back from a web page to a Silverlight App in a different domain?
  18. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 24 May 2013 Link to this post

    Hello Anne,

    This communication doesn't really depend on the RadHtmlPlaceholder as it is rather a cross-domain issue. You can take a look at this article for more information.

    Regards,
    Tina Stancheva
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner