Please Help Friends
1 ViewData
2 ViewBag
3 TempData
4 Session
Get The Value In Page Using MVC4 Please Help Me
Get The Value In View Using Jquery
How To Get Value ViewData, View Bag And TempData in Jquery
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 28, 2015, 10:12 PM EST
$('input,select').attr('disabled','<%=Session["CoBrowse"].ToString() %>');
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 28, 2015, 10:10 PM EST
The easiest way I can think of is to use a JavaScriptSerializer and embed the values into your javascript, kind of like:
<%
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
%>
same way ViewBag TempData can be used
Muralishankar Sundaram114 reputationPosted Mar 14, 2015, 4:03 AM EDT
var elementId= "@ViewData["ID"]";
or
var elementId = '@ViewBag.ID';
or
var elementId = '@TempData["ID"]';
var element=$("#"+elementId);
Note:
you can only able to get the string value in the javascript.
Thanks