开发者

Html.Hidden() inserting wrong value

When I use a form html helper method in one of my views like <%=Html.Hidden("id", "some id text") %> it creates a hidden input field for me but it puts the wrong value in there.

Instead of getting

<input name="id" type="hidden" value="some id text"/>

I get

<input name="id" type="hidden" value="11000"/>

So the value is being found from somewhere else. In this case it's the primary id of the parent record. So it is an id, it's just the wrong id.

Does anyone have any ideas? I'm pretty sure this didn't happen i开发者_开发知识库n MVC1


Model binding always takes precedence. The model binder doesn't know of if a field is hidden. See http://forums.asp.net/t/1559541.aspx and http://forums.asp.net/t/1703334.aspx


I can thing about following options

  1. Value you are passing to the view is wrong, eg. data passed to view(you can check debugging in controller to see what are you passing into it
  2. You are using ViewData and TempData data with different values which are overridden

else please put here your code so we all can see what is wrong

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜