开发者

problem in Accessing ViewData in javascript+MVC3

I am required t开发者_StackOverflow中文版o assign ViewData["file"]'s value to an html hidden control through javascript/jQuery


You need to have

<script>
   $(document).ready(function(){
     $("[name=hdnHiddenField]").attr("value",@ViewData["file"]);
   });
</script>

and in your view:

<input type="hidden" name="hdnHiddenField"/>

Note that you cannot have this script in an external js file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜