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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Muralishankar SundaramPosted Mar 14, 2015, 8:03 AM
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
Manish Kumar ChoudharyPosted Jan 29, 2015, 3:12 AM
$('input,select').attr('disabled','<%=Session["CoBrowse"].ToString() %>');
Manish Kumar ChoudharyPosted Jan 29, 2015, 3:10 AM
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