[转]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 ...
随机推荐
- 适合新手看的ref和out
面试的时候一般很高的概率会问到ref和out的区别...我们死记硬背的话很难记住. 建议大家和我一样简单的探索一下.动手试一下就能记住了. 共同点是我们在使用ref或者out的时候一定要在写的方法里面 ...
- 【cocos2d-x 手游研发----精灵的八面玲珑】
继续上一篇文章继续聊吧,这章内容会比较多,也会附上代码,很多朋友加了群,大家在群里面探讨了很多东西,这让大家都觉得受益匪浅,这便是极好的,废话不多了,精灵是游戏的重要组成部分,那ARPG里面的精灵必然 ...
- Kotlin 基本语法
常量 val a: Int = 5 变量 var a: Int = 5 Any:匹配任何类型 ?:nullable,比如 a?.toString,如果 a 为 null 不会出错. 函数基本结构 fu ...
- FFMpeg音频重采样和视频格式转
一.视频像素和尺寸转换函数 1.sws_getContext : 像素格式上下文 --------------->多副图像(多路视频)进行转换同时显示 2.struct SwsContext ...
- hdoj1175 连连看(dfs+剪枝)
处理连连看问题. 要求拐弯方向不多于两次.剪枝很重要!!! 用dir记录当前方向.Orz,居然没想到. #include<iostream> #include<cstring> ...
- [ActionScript 3.0] UDP通信
package com.controls.socket { import flash.events.DatagramSocketDataEvent; import flash.events.Event ...
- jvm内存结构(一)(结构总览)
jvm内存结构:<Java虚拟机原理图解>3.JVM运行时数据区 程序计数器: ,是执行的字节码的行号指示器,记录的是正在执行的虚拟机字节码指令的地址. ,每个线程都有独立计数器,互不干扰 ...
- iOS-电池图标【结合贝塞尔曲线控制电量显示】
基于UIView类:WKJBatteryView WKJBatteryView.h #import <UIKit/UIKit.h> @interface WKJBatteryView : ...
- 剑指offer二十一之栈的压入、弹出序列
一.题目 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序 ...
- linux内核模块的安全
linux可以动态的加载内核模块,在很多场合可能需要确保加载内核的安全性.如果被攻击者加载恶意内核模块,将会使得内核变得极其危险. 当然,稳妥的做法就是给内核模块进行签名,内核只加载能正确验证的签名. ...