I guess how do I get the reference to the silver light object which is hosting the html placeholder. The Javscript function that needs the reference of silverlight object is in the html hosted by the htmlplaceholder.
7 Answers, 1 is accepted
But, what I am looking for is reverse order. I need to call a function in silverlight control from the html hosted by the htmlplaceholder.
I am not sure if I understand you correctly, you ask:
" I need to call a function in silverlight control from the html hosted by the htmlplaceholder."
1. If you mean how to call in Silverlight a JavaScript function from the HTML hosted by the Htmlplaceholder then all you need to do is the following:
in JavaScript
function test() {
window.alert("This is a test function");
}
in Silverlight
// Get the IFrame from the HtmlPresenter
HtmlElement iframe = (HtmlElement)RadHtmlPlaceholder1.HtmlPresenter.Children[0];
// Set an ID to the IFrame so that can be used later when calling the javascript
iframe.SetAttribute("id", "myIFrame");
// Code to be executed
string code = "document.getElementById('myIFrame').contentWindow.test();";
HtmlPage.Window.Eval(code);
2.If you want to call managed C# code from JavaScript then take a look at the following articles:
http://silverlight.net/quickstarts/htmlbridge1.aspx#html_bridge_overview
http://msdn.microsoft.com/en-us/library/cc221414(VS.95).aspx
Please l
I have a silverlight page which includes a RadHtmlPlaceholder.
RadHtmlPlaceholder has a web page which has controls (e.g. buttons).
When the button is clicked, I want to handle that event in Silverlight.
This article points to Microsofts article
http://silverlight.net/quickstarts/htmlbridge1.aspx#html_bridge_overview
Which shows some sample code like..
public Page()
{
InitializeComponent();
HtmlDocument htmlDoc = HtmlPage.Document;
...
// Add an event handler for the Convert button.
HtmlElement
htmlEl = htmlDoc.GetElementById("Convert");
htmlEl.AttachEvent("onclick", new EventHandler(this.OnConvertClicked));
}
void OnConvertClicked(object sender, HtmlEventArgs e)
{
}
But this is for caller page not RadHtmlPlaceholder. Please show some samples for RadHtmlPlaceholder.
I need help mainly on how to get the HtmlElement inside
RadHtmlPlaceholder by name.
the article you are pointing to is working when the buttons are on the same page where the silverlight application is. Since you are using external page this will not be possible.
If the page you are using is from the same domain you can still do it, but in a very different way.
You will need first to handle the button clicks inside the page where you have registered the Silverlight application. Then you can simply call a method from the Silverlight application to get notified about the button click.
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.
You can also check this thread for more info:
http://www.telerik.com/community/forums/silverlight/htmlplaceholder/accessing-managed-code-from-htmlplaceholder-control.aspx
Best wishes,
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.
I am using RadHtmlPlaceholder in my application. i wanted to show the currently installed silverlight plug-in version in that place holder. I am having a HTML page which will display the installed silverlight client version. But when i set the HTML place holder source as that HTML page code, it is not displaying the installed SL lient version.
Could you please send me the code to display the installed SL plug-in version. Or provide some pointers on that.
Thanks,
Kiran
The html placeholder has no relation to the html page that you are displaying. What it does is to pass the source of the html page to an IFrame and display it. Are you saying that the html placeholder does not display the html page at all or just parts of it (where the SL plugin version is)?
Kind regards,
Alex Fidanov
the Telerik team