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"] %>');
    }
}
}
5
  • 1
    We need to see your actual code, what you made of those links. Commented Feb 26, 2014 at 10:57
  • we need to see your code Commented Feb 26, 2014 at 11:07
  • Sir i updated my code in my question. please see the above code. Commented Feb 26, 2014 at 11:25
  • @user1919099 your code is looking fine but i hope you have code block problem so refer this link it my useful to you.stackoverflow.com/a/1176779/2798643 Commented Feb 26, 2014 at 13:17
  • Please check this answer stackoverflow.com/a/25997455/3991984 Hope it helps. Commented Sep 23, 2014 at 14:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.