I want to access a Session value in jquery method in the ASP.NET MVC view page. See the below code,
$(\'input[type=text],select,input[type=checkbox],input[ty
Many comments:
:checkbox, :text, etc.true or false on the right place. is also a disabled check box, so your controls are always disabled.If that is the way you choose anyway, consider:
var isCoBrowse = <%= Session["Name"].ToString().ToLower() %>;
if(!isCoBrowse) //disable controls
$(":text,:checkbox,:radio").attr("disabled","disabled"); //standard.
This will produce the client-side JavaScript code:
var isCoBrowse = true;
And, to enable an element:
$("input").removeAttr("disabled");
Also, there are much better ways to accomplish this. Have you considered disabling the controls on server side, if possible?