I was trying to create a bing map silverlight application to be hosted on a custom SharePoint form page. This form is displaying the properties of a specific content type and within this content type I have two fields one for Latitude and one for Longitude. The requirement is actually to app to this form a Silverlight bing map that would display the location of this item. Also the solution should does not require any farm solutions as this is a sandbox environment.
I tried first to pass the initialization parameters to the silverlight application through the out of the box silverlight web part “Custom Initiation Parameters” but the thing is that these parameters are constant values and I even tried to get form values using scripts on this string but the string just got HTML encoded and passed as is to the silverlight application.
The option I had working is to use JScript from the silverlight application to read the form parameters. To do this I first created a hidden calculated column by display=none and not the column itself being hidden from the server side. and in that column I concatenated both values in one comma separated string as so
Then I changed the silverlight main application class to be somethig like this
public partial class App : Application
public string strLocation;
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
System.Windows.Browser.HtmlDocument doc = System.Windows.Browser.HtmlPage.Document;
System.Windows.Browser.HtmlElement elem = doc.GetElementById(“SPFieldCalculated”);
strLocation = elem.GetProperty(“innerText”).ToString();
Then I read this value from my main window and parse the reguired paramters.
You must log in to post a comment.