在jquery asp.net中获取mvc模型项c# [英] get mvc model items in jquery asp.net c#
本文介绍了在jquery asp.net中获取mvc模型项c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我想问一下如何从jquery中获取mvc模型的值..
这里是我的代码
hey every one i want to ask how to get the values from mvc model in jquery..
here is my code
<pre lang="xml"><script type="text/javascript">
$(document).ready(function () {
for (var j = 0; j < '@Model.Count' / 2; j++)
{
getHalfViewPage('@(Html.Raw(Url.Action("LoadReports", "Dashboard", new { @area = "Home", showfullWidth = true, DMFormDefKey = Model.ElementAt(0).deffromkey }, Request.Url.Scheme)))', "halfViewList1-" + j);
}
< / script>
这是Model.ElementAt(0) .deffromkey总是通过零0。如何获得原始价值。请帮帮我..
</script>
this is "Model.ElementAt(0).deffromkey" always pass "zero 0". how to get the orignal value. please help me..
推荐答案
(文件).ready(function(){
(document).ready(function () {
for (var j = 0; j < '@Model.Count' / 2; j++)
{
getHalfViewPage('@(Html.Raw(Url.Action("LoadReports", "Dashboard", new { @area = "Home", showfullWidth = true, DMFormDefKey = Model.ElementAt(0).deffromkey }, Request.Url.Scheme)))', "halfViewList1-" + j);
}
< / script>
这是Model.ElementAt (0).deffromkey总是传递零0。如何获得orignal值。请帮助我..
</script>
this is "Model.ElementAt(0).deffromkey" always pass "zero 0". how to get the orignal value. please help me..
<script type="text/javascript">
var yourModel = '@Html.Raw(Json.Encode(Model))';
// yourModel now contains your MVC (server side) model as json serialized model.
alert(yourModel.whatEverPropertyYouWant);
</script>
这篇关于在jquery asp.net中获取mvc模型项c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文