I use ASP.NET with VB. myDataSet is a DataSet with some data. I want to save the DataSet XML to Local Storage and then load the item from Local Storage offline. But now I seem to be failed to write the item of xml to Local Storage. Does somebody know how
to solve this problem?
Dim xml As String = myDataSet.GetXml()
Dim str As String = "<script> localStorage.setItem('key1', '" & xml & "'); </script>"
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "showmessage1", str, False)
Are you using ASP.NET AJAX? I got doubt since you are calling RegisterClientScriptBlock method on
ScriptManager! if you are not using, then try to call it using -
Page.ClientScript.RegisterStartupScript
akira32
Member
5 Points
18 Posts
ASP.NET Local Storage save a item of DataSet XML failture
Dec 13, 2012 05:22 AM|LINK
I use ASP.NET with VB. myDataSet is a DataSet with some data. I want to save the DataSet XML to Local Storage and then load the item from Local Storage offline. But now I seem to be failed to write the item of xml to Local Storage. Does somebody know how to solve this problem?
Dim xml As String = myDataSet.GetXml() Dim str As String = "<script> localStorage.setItem('key1', '" & xml & "'); </script>" ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "showmessage1", str, False)roopeshreddy
All-Star
20135 Points
3323 Posts
Re: ASP.NET Local Storage save a item of DataSet XML failture
Dec 13, 2012 06:13 AM|LINK
Hi,
Before using HTML5 LocalStorage, it's better to check whether the browser supports it.
http://roopeshreddy.wordpress.com/2011/12/25/localstorageavoid-cookies/
Moreover, You can also check this thread - http://stackoverflow.com/questions/3232872/is-5mb-the-de-facto-limit-for-w3c-web-storage
Are you using ASP.NET AJAX? I got doubt since you are calling RegisterClientScriptBlock method on ScriptManager! if you are not using, then try to call it using - Page.ClientScript.RegisterStartupScript
http://msdn.microsoft.com/en-us/library/z9h4dk8y.aspx
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
raju dasa
Star
14320 Points
2440 Posts
Re: ASP.NET Local Storage save a item of DataSet XML failture
Dec 13, 2012 07:21 AM|LINK
Hi,
Check this site for localStorage store limitations:
http://dev-test.nemikor.com/web-storage/support-test/
or alternatively use IndexedDB. (check my blog below).
rajudasa.blogspot.com || blog@opera
akira32
Member
5 Points
18 Posts
Re: ASP.NET Local Storage save a item of DataSet XML failture
Dec 13, 2012 12:33 PM|LINK
I had resolved this problem
Dim xml As String = sqldsPHIS.GetXml()
xml = xml.Replace("" & vbCrLf & "", " ")
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="SaveLS()"/> <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="LoadLS()"/> <input type="hidden" id="hiddenbox" runat="server"/> <script> function SaveLS() { localStorage.setItem("key1", "abc"); } function LoadLS() { var d = localStorage.getItem('key1'); var c = document.getElementById('FeaturedContent_hiddenbox'); c.value = d; alert(c.value); } </script>Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim b As String = hiddenbox.Value End Sub