8

HiddenFor description is: Returns an HTML hidden input element for each property in the object that is represented by the specified expression.

I read that it is useful for fields in your Model/ViewModel that you need to persist on the page and have passed back when another call is made but shouldn't be seen by the user.

HiddenInput description is: Represents an attribute that is used to indicate whether a property or field value should be rendered as a hidden input element.

Can you please tell me when is HiddenInput useful? and when to use it instead of Html.HiddenFor?

Thanks!

1
  • Out of interest, what is the source of your descriptions for these extension methods? Commented Sep 2, 2012 at 17:51

1 Answer 1

12

HiddenFor is determined by the view - the view creates a Hidden input value from any element of the viewmodel or data.

HiddenInput is an attribute on a field in the (view)model - which means that it can be used across multiple views and indicates that this field should be hidden wherever it is rendered by an EditorFor helper

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.