1

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 parametr is 4 in both cases ???

Zdenek G
  • 341
  • 1
  • 5
  • 17
  • possible duplicate of [Possible bug in ASP.NET MVC with form values being replaced](http://stackoverflow.com/questions/594600/possible-bug-in-asp-net-mvc-with-form-values-being-replaced) – Bertrand Marron Aug 26 '11 at 09:30

1 Answers1

0

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

cpoDesign
  • 8,953
  • 13
  • 62
  • 106