I have a model:
public class Attribute
{
public int Id { get; set; }
public string Key { get; set; }
public string Value{ get; set; }
}
Let’s say my view will display @model IEnumerable<MyCustomer.ViewModels.Attribute>, I want to make a EditorFor for my key and value but I just want to retain my Id without after a postback without putting it into a postback control. How can I acheive this? I know I can put it in a hidden but a hidden can be modified and I’m not sure it’s the safest thing to do. I am passing a new[] of attributes to my view and the Id needs to be preset
The following post offers up an approach to the problem by creating a secure hash of the value for the hidden field.
The post also links to an article with sourcecode for a SecuredValueHtmlHelper which sounds like just what you need.
Prevent change of hidden field