开发者

problem in Accessing ViewData in javascript+MVC3

开发者 https://www.devze.com 2023-03-27 13:12 出处:网络
I am required t开发者_StackOverflow中文版o assign ViewData[\"file\"]\'s value to an html hidden control through javascript/jQueryYou need to have

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

精彩评论

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