I want to send a string I built using the StringBuilder to the HTML page, which then I want to use in my JavaScript code.
Right now here’s what I am doing:
On the client side:
<div id="data">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</div>
In my JS block:
var data = $("#data").html();
In the code behind:
Literal1.Text = strXml.ToString();
The thing is, this data can be seen by going through the source of the data div, which I dont want to allow.
I want this string as soon as the page loads, so I guess making an AJAX call after the page has loaded to the server is out of the way.
Any smoother way ?
It’s a .NET rookie here.. 🙂
you can save your string in an
HiddenFieldthen read its value using javascript something like thisin code behind
javascript
or you can define
strXmlasprotectedvariable and use it inside.aspxlike thatjavascript code will like this