I am trying get the session value in javascript in my asp.net code behind.
But the syntax is wrong I don't know how to get the session value.
Here in my question i trying to set the value of sesindex variable which is a session value which i dont know how to set its totaly different
I tried to call javascript on page load normally its calling is fine. But when I am trying to set the variable value as session value its not calling alert box so their some where I put wrong but I don't know what it is.
Here is the code behind code:
str += "<script type='text/javascript'>" +
//"alert('testing');" +
"var sesindex = '<%=Session["indexval"]%>';" +
"alert(sesindex);" +
"</script>";
I want to set sesindex value and show in alert box. I am trying to set the value but its not working. It is working fine in html page. But its not working in code behind.
RegisterStartupScript/RegisterClientScriptBlockalready? How you're inject the script into ASPX page?["indexval"]should have thrown an exception. This version will work on aspx side of things where'<%=Session["indexval"]%>'will be rendered to something.