Client-Side DataSet
A couple of days ago somebody asked me about calling WebServices using JavaScript whithin the WebBrowser. He was using XMLHTTP object within IE calling a simple WebService passing parameters in the URL. But he get into trouble when the WebService returns a hard-typed DataSet because he have to use DOM (XPath) to get the data within the DataSet's XML.
This is a simple but ugly solution because samobidy could could change a "field" from Element(default) to Attribute; all the code in C#(for example) using the DataSet generated class, will be compatible, but the XML is different.
A couple of months ago i wanted to develop a Client-Side Dataset providing similar API to use a DataSet but coded in JavaScript so it can be used inside the browser. I started coding some lines this morning but is not a simple solution, and i have a lot of work to do :).
I was thinking on the following solution:
- Creating a ServerControl with a single property named DataSetType. In design time the developer places the ServerControl in a page setting the property to a DataSet type.
- During server control rendering, it uses reflection and XSD information to generate enough JavaScript code so an XML could be readed and supporting a DataSet like programming interface.
- The script generated also creates a new instance of an empty the Dataset so the user can execute the following code in JavaScript: someDataSet.LoadXml( xmlString ); alert( someDataSet.Tables[0][0] );
Monday is a non-working day in Argentina, so i'll try to get some code working and perhaps post the code in a Workspace. Does anybody knows if someone else is working on somthing similar?