Microsoft Visual Studio LightSwitch is designed to help business users and developers quickly create data-based applications with minimal code. However, we can reduce our efforts further by using ComponentOne controls in it. In this blog, we will see how C1HtmlHost can be used in a LightSwitch application. The HTML host control (C1HtmlHost) provides a frame that can host arbitrary HTML content, and display content from arbitrary URIs or HTML text. You may refer to its documentation for more information. Here are few simple steps which you can follow to achieve the same:
Once, C1HtmlHost control is added, then you need to handle the Created event of the screen and use the below code to access the control:
partial void HTMLHostScreen_Created()
{
IContentItemProxy _proxy = this.FindControl("MyHtmlhost");
\_proxy.ControlAvailable += new EventHandler<ControlAvailableEventArgs>(\_proxy_ControlAvailable);
}
void \_proxy\_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
var htmlhost = e.Control as C1HtmlHost;
htmlhost.SourceUri = new Uri("http://www.componentone.com/");
}
Moreover, C1HtmlHost is a Web-based control so you need to change the Application type of the project from Desktop to Web.
And that's it. You have successfully added C1HtmlHost control in a LightSwitch application. But, here is the catch. When you will run this application then it show an error i.e. "To use this control the Silverlight plugin must have its 'windowless' parameter set to true". This error can resolved by going through the below steps: