开发者

Possible to work with Isolated Storage from Javascript?

开发者 https://www.devze.com 2023-03-06 01:19 出处:网络
I\'m needing to delete a value in Isolated storage from javascript code. If this is possible how is it done? I found some co开发者_如何学Gode from a post written in 2007 and Silverlight has changed a

I'm needing to delete a value in Isolated storage from javascript code.

If this is possible how is it done? I found some co开发者_如何学Gode from a post written in 2007 and Silverlight has changed a lot since then.


The best way would be to call a Silverlight method from JavaScript. This link provides examples on how to handle this:

http://weblogs.asp.net/mschwarz/archive/2007/06/01/call-scribtable-methods-from-javascript-with-silverlight.aspx


Expatiating Keith Adler's answer a bit...

IsolatedStorage can only be accessed by managed code, which is a term Microsoft uses to refer to code in one of the .NET languages. Fortunately, Javascript can be used to communicate with managed code, and vice-versa. As shown in the article you linked, this is done through a Silverlight object.

Microsoft has a set of very detailed walk-through articles on this very topic. But perhaps you and others would prefer (or perhaps more appropriately, would have preferred) an existing solution over rolling out your own.

If that's the case, check out BakedGoods. Its a Javascript library that establishes a uniform interface that can be used to conduct common storage operations in all native, and some non-native storage facilities, including IsolatedStorage.

With it, you can accomplish what you want by using something like the following code snippet:

bakedGoods.remove({
    data: ["targetItemKey"],
    storageTypes: ["silverlight"],
    complete: function(byStorageTypeRemovedItemKeysObj, byStorageTypeErrorObj){/*code*/}
});

Oh, and for the sake of complete transparency, BakedGoods is maintained by none other than yours truly :) .

0

精彩评论

暂无评论...
验证码 换一张
取 消