开发者

Html.Hidden returns different value

I have problem, which i can't understand.

int i = Convert.ToInt32(Model.dt);
MvcHtmlString s = Html.Hidden("DishType", Convert.ToInt32(Model.dt));
MvcHtmlString ss = Html.Hidden("DishType", 4);

i = 4

s = input id="DishType" name="DishType" type="hidden" value="22"

ss = input id="DishType" name="DishType" type="hidden" value="22"

Why value is 22, if para开发者_运维技巧metr is 4 in both cases ???


this is because you passed in on wrong location

what you need to use is:

<%= Html.Hidden("name",null,new{Value = "your attributes here"}) %>

Also read up about this here: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.WEB.MVC.HTML.INPUTEXTENSIONS.HIDDEN%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29;k%28DevLang-CSHARP%29&rd=true

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜