GD Bloggers

This is the blog site for Microsoft Global Delivery Communities focused in sharing the technical knowledge about devices, apps and cloud.
Follow Us On Twitter! Subscribe To Our Blog! Contact Us

Reading SharePoint Form Data from Silverlight application

Reading SharePoint Form Data from Silverlight application

  • Comments 1
  • Likes

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

=CONCATSTRING([Latitude],",",[Longitude])

Then I changed the silverlight main application class to be somethig like this

   public partial class App : Application

    {

public string strLocation;

public App()

        {

 this.Startup += this.Application_Startup;

this.Exit += this.Application_Exit;

this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();

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.

Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment