[转]Pass a ViewBag instance to a HiddenFor field in Razor
2017-12-04 10:26
429 查看
本文转自:https://stackoverflow.com/questions/27456983/pass-a-viewbag-instance-to-a-hiddenfor-field-in-razor
You are getting this error because ViewBag is dynamic type. You can use ViewModel instead of ViewBag to solve this problem.
Alternatively you can use following or plain html as suggested by iceburg:
Try casting the return value to
You are getting this error because ViewBag is dynamic type. You can use ViewModel instead of ViewBag to solve this problem.
Alternatively you can use following or plain html as suggested by iceburg:
@Html.Hidden("id", (string)ViewBag.PortfolioId) https://stackoverflow.com/questions/10179015/mvc-razor-html-helper-syntax-viewbag-in-html-hidden-object-parameter
Try casting the return value to
object:
@Html.Hidden("hiddenDate", (object)ViewBag.myDate.ToString("dd.MM.yyyy"))
相关文章推荐
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance
- How to set a hidden value in Razor
- How to pass new hidden value to backing bean in JSF
- Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection
- sql express 2008 - Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instan
- UIView Tutorial for iOS: How To Make a Custom UIView in iOS 5: A 5 Star Rating View
- appium for python client scroll to view(not in current screen)
- How to pass List from Controller to View in MVC 3.
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection
- -[UIWindow viewForFirstBaselineLayout]: unrecognized selector sent to instance
- -[UITextTapRecognizer velocityInView:]: unrecognized selector sent to instance 0x6080003c3a20
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection
- 个人总结 .net MVC Controller to View for value(ViewData and ViewBag)
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection
- Android - Failed to find provider info for com.google.settings in MapView Example
- 关于Error in PL/SQL block to clean upleftover entries for SDE instance ORA-06508....
- [UIView numberOfComponentsInPickerView:]: unrecognized selector sent to instance
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection