Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Access clientside data island? RSS

6 replies

Last post May 14, 2008 05:29 AM by Yi-Lun Luo - MSFT

(0)
  • benji2

    benji2

    Member

    9 Points

    9 Posts

    Access clientside data island?

    May 12, 2008 06:51 PM | LINK

    Hi,

    I'm wondering if I can use ASP.NET 2.0 to push a client side XML data island, and then, on the client side, access that XML data island from a Silverlight 2.0 Beta 1 control. Has anyone gotten this to work? Any example code would be great.

    Thanks..

    -Ben

    XML "Silverlight 2"

  • James Osborne

    James Osborne

    Member

    90 Points

    23 Posts

    Microsoft

    Re: Access clientside data island?

    May 12, 2008 11:15 PM | LINK

    I'm not sure about the first part of the question... but what form will the XML be in on the client?  (A file somewhere?  CLR object in a different app?  Message object ready to dispatch somewhere?)

     

    James
  • benji2

    benji2

    Member

    9 Points

    9 Posts

    Re: Access clientside data island?

    May 12, 2008 11:25 PM | LINK

    Hi James,

    Something like this is what I was referring to:

    http://msdn.microsoft.com/en-us/library/ms766512(VS.85).aspx

    I'm evaluating how to get data from my db displayed via a silverlight control. I could go with a web service, but I started thinking that if I could somehow dump the display data at the same time as generating the surrounding page (perhaps dumping the data IN the page as the link above describes), that should save me some serveroverhead I think.

    -Ben

  • James Osborne

    James Osborne

    Member

    90 Points

    23 Posts

    Microsoft

    Re: Access clientside data island?

    May 12, 2008 11:37 PM | LINK

    This sounds really interesting.  My first approach would be the webservice one, but that's because until now, I haven't heard of Xml Data Islands.  Maybe you could issue an HttpWebRequest to the page that has the data island on it.  Then manually parse the response message for the XML.

    James
  • samcov

    samcov

    Participant

    1629 Points

    697 Posts

    Re: Access clientside data island?

    May 13, 2008 01:14 AM | LINK

    This doesn't really apply to SilverLight(SL).

    XML Data Islands existed because there was no native javascript way to manipulate XML data.

    Well, in SL, you can do anything you want with XML, including using Linq, however, you have two options.

    1. The SilverLight Way:  Grab the XML data/file/webservice from wherever it is on the server, then parse it to extract meanigful data into a List or anonymous type, and use it for whatever purpose(fill out a form, etc.)
    2. The Old Way:  Keep the Data Island in the browser, and use the SL Javascript API to grab the xml from Javascript.

    Either way works, however, I prefer to do all of my processing(when possible) in C# rather than Javascript(faster and easier to debug).

    I hope this helps.

    Sam...

  • benji2

    benji2

    Member

    9 Points

    9 Posts

    Re: Access clientside data island?

    May 13, 2008 01:39 AM | LINK

    Hi Sam,

    >The SilverLight Way:  Grab the XML data/file/webservice from wherever it is on the server

    I think there are a lot of scenarios where exposing data from the server (say via a web service) makes sense. I imagine a scenario where the user can interact with the silverlight control and request a different set of data. However, in my circumstance, the control will only display data, and there will be no possibility of needing to query for another set of data.

    That being said, with option 1 you suggest, the ASP.NET page is rendered, and once the client loads the page (and the SL control), it will generate another request (to the web service exposing the data). With option number two, there is no additional (web service) request; the page is rendered once and the client already has everything handed to it to display the page and the SL control.

    >I prefer to do all of my processing(when possible) in C# rather than Javascript(faster and easier to debug).

    I completely agree. I may be missing something though: In either circumstance I think I'd be using C# clientside. I would still envision using LINQ to XML in either circumstance to load the XML into an object for the SL object to consume. Also, I think that there is a managed API which is callable from SL used for accessing the clientside DOM.

    I was reading somewhere that XML data islands are only supported in IE and should be avoided. Perhaps there are alternate solutions to this. Maybe somehow pushing a temporary xml file to the browser?

    Thanks for the response.

    -Ben

  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: Re: Access clientside data island?

    May 14, 2008 05:29 AM | LINK

    Hello, if your xml file is static, you can embed it into the Silverlight xap file. Just set its build action to Content, and then it'll be downloaded to the client together with your Silverlight assembly. You can use the XmlXapResolver to load the xml file. Please refer to http://msdn.microsoft.com/en-us/library/cc189040(vs.95).aspx. If you must construct the xml data dynamically, however, you can't use this option... I don't think xml data island is a good option either. As the document points out:

    [This feature was implemented for MSXML 3.0. Later versions of MSXML might not support it.]

    So even IE may no longer support it in the future. But just a single extra web request won't cause too many performance issues, right?

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.