[转]Pass a ViewBag instance to a HiddenFor field in Razor
本文转自: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:
@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"))
[转]Pass a ViewBag instance to a HiddenFor field in Razor的更多相关文章
- viewbag
How does ViewBag in ASP.NET MVC work behind the scenes? https://stackoverflow.com/a/16950197/3782855 ...
- 【总文档】rac增加新节点的方法步骤 How to Add Node/Instance or Remove Node/Instance in 10gR2, 11gR1, 11gR2 and 12c Oracle Clusterware and RAC
[总文档]How to Add Node/Instance or Remove Node/Instance in 10gR2, 11gR1, 11gR2 and 12c Oracle Clusterw ...
- Java SE 8 docs——Static Methods、Instance Methods、Abstract Methods、Concrete Methods和field
一.Static Methods.Instance Methods.Abstract Methods.Concrete Methods ——Static Methods:静态方法 ——Instance ...
- C# ftp 图片上传多快好省
前言 此篇讲到的是图片上传功能,每个网站必定会有这样类似的功能,上传文件.上传图片等等.那么接下来,看看我们EF+uploadfile+ftp如何玩转上传图片吧 效果预览 具体实现 一个简单数据库 只 ...
- iOS编码规范
The official raywenderlich.com Objective-C style guide. This style guide outlines the coding con ...
- EF DI & MVC
The Repository Pattern with EF Code First & Dependency Injection in ASP.NET MVC3 Ray_Liang, 5 Ju ...
- EF UoC
The Repository Pattern with EF Code First & Dependency Injection in ASP.NET MVC3 Ray_Liang, 5 Ju ...
- Python自动化之django的ORM操作——Python源码
""" The main QuerySet implementation. This provides the public API for the ORM. " ...
- ExtJS笔记 Field
Fields are used to define what a Model is. They aren't instantiated directly - instead, when we crea ...
随机推荐
- NPOI datatable导出类
using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using System; using System.Collections.Generic; ...
- musql 添加字段语句
修改表tax_version添加up_content属性为text类型非空,注释为“更新内容”,字段添加再“name”属性后面 ALTER TABLE `tax_version` ADD `up_co ...
- 创建自己的Code Snippet(代码模板)
一.名词解释 Code Snippet,代码模板,是一种快速生成代码的快捷方式,使用它可以有效地提高编程效率. 编程中可以使用Visual Studio提供的预先设置好的Code Snippet,也可 ...
- UE4随笔(一)准备过程
19号,也就是中国时间20日凌晨,虚幻4放出了"订阅制"这个重磅炸弹,估计出乎大多数人的想象,已经不止一个同事表示"自己的引擎这下没用了". 笔者前天搞定了付款 ...
- 企业项目开发--分布式缓存memcached(3)
此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 3.3.ssmm0-data 结构: 3.3.1.pom.xml 1 <?xml version=& ...
- ng的点滴记录
1,directive http://damoqiongqiu.iteye.com/blog/1917971/ 2,constructor https://segmentfault.com/q/10 ...
- PHP 5.6 如何使用 CURL 上传文件
以前我们通过 PHP 的 cURL 上传文件是,是使用“@+文件全路径”的来实现的: curl_setopt(ch, CURLOPT_POSTFIELDS, array( 'file' => ' ...
- eclipse上搭建Spring环境
搭建环境之前要下载Spring Tool Suite和Spring framework 1.Spring IDE 下载(也叫Spring Tool Suite 简称 STS),进官网,直接给链接htt ...
- day 55 linux 的常用命令
前言 前面咱们已经成功安装了Linux系统--centos7,那么我们现在提好裤腰带,准备奔向Linux的大门. Linux命令行的组成结构 [root@oldboy_python ~]# [roo ...
- OpenCV --- 修改图像的对比度、亮度 、RGB转Gray图像、修改图像的尺寸
#include <opencv2/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgu ...