This is a migrated thread and some comments may be shown as answers.

Accessing Managed Code From HTMLPlaceHolder Control

16 Answers 172 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 07 Sep 2009, 02:41 AM
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

16 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 07 Sep 2009, 08:53 AM
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.
0
Dave
Top achievements
Rank 1
answered on 08 Sep 2009, 12:19 PM
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.
0
Valentin.Stoychev
Telerik team
answered on 08 Sep 2009, 12:42 PM
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.
0
Dave
Top achievements
Rank 1
answered on 08 Sep 2009, 12:46 PM
I am using the SourceUrl property of the HTMLPlaceHolder Control to set the uri. 
0
Dave
Top achievements
Rank 1
answered on 09 Sep 2009, 04:16 AM
Is there any additional information on this topic?

Thanks 
0
Valentin.Stoychev
Telerik team
answered on 09 Sep 2009, 08:26 AM
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.
0
Dave
Top achievements
Rank 1
answered on 09 Sep 2009, 10:18 AM
That looks like what I need.  Thanks!

0
Srinivas
Top achievements
Rank 1
answered on 10 Sep 2009, 01:05 AM
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);

 

}

0
Valentin.Stoychev
Telerik team
answered on 10 Sep 2009, 07:45 AM
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.
0
Srinivas
Top achievements
Rank 1
answered on 14 Sep 2009, 10:08 PM
I have fixed this issue. It had to do with me not setting the id of Silverlight control right.

Thanks a lot.
0
Jason
Top achievements
Rank 1
answered on 13 Oct 2009, 06:14 AM
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?
0
Valentin.Stoychev
Telerik team
answered on 13 Oct 2009, 07:21 AM
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.
0
Mitch Newlin
Top achievements
Rank 1
answered on 23 Nov 2010, 11:14 PM
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?
0
Kiril Stanoev
Telerik team
answered on 26 Nov 2010, 09:22 AM
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
0
Anne Lyon
Top achievements
Rank 1
answered on 22 May 2013, 09:35 AM
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?
0
Tina Stancheva
Telerik team
answered on 24 May 2013, 08:17 AM
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.

Tags
HTMLPlaceHolder
Asked by
Dave
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Dave
Top achievements
Rank 1
Srinivas
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Mitch Newlin
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Anne Lyon
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or