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.
精彩评论