0

Actually i need a functionality like i want to assign a session variable in java script ...when i researched so many people said we cant do it but in some blogs i found we can assign and we can get.....here below are the links that they said possible

How to access Session variables and set them in javascript?

http://shekharshetemcts.wordpress.com/2013/11/27/how-to-access-session-variables-using-javascript-in-asp-net/comment-page-1/#comment-294

but my problem is when i am using that code i am getting an error like below

Error:-The Controls collection cannot be modified because the control contains code blocks (i.e. ).

Below is my javascript code

function showorhide(id) {
    if (document. getElementById (id).style.display == "none") {
    document. getElementById (id).style.display = "block";
    var idA = id;
    if (idA == "workdiv3") {
        var id = "10";
        '<%Session["x"] = "' + id + '"; %>';

        alert('<%=Session["x"] %>');
    }
    } 
else {
    document . getElementById (id).style.display = "none";
    var idA = id;
    if (idA == "workdiv3") {
        var id = "11";
        '<%Session["x"] = "' + id + '"; %>';

        alert('<%=Session["x"] %>');
    }
}
}
Community
  • 1
  • 1

0 Answers0