Client-side scripting comes with a bunch of limitations. There's no client storage you can read from or write to. You can't read from files a user selected from your <input type='file' /> element, etc. To address this, I've encapsulated a few services that Silverlight enables. I have packaged this up as an ASP.NET control, but nothing prevents you from directly using the Silverlight assembly and host it on an arbitrary webserver.
For the results of this control, check out the ClientServices demo. Or download the control's source-code.
1
2
3
4
5
6
7
8
9
10
|
function saveDraft() {
/* Get the scriptable, managed services object */
var services = $get("clientServices").Content.services;
var messageTextBox = $get("messageTextBox");
/* Save the contents of the textbox in a file called Draft.txt on the
client, using isolated storage. We can read from this using
services.ReadFile("Draft.txt"), even if the user restarted the browser. */
services.SaveFile("Draft.txt", messageTextBox.value);
}
|