views:

545

answers:

2

Which should I use?

<input type="hidden" name="first_name" 
value="<%= person.first_name %>" />

or

<input type="hidden" name="first_name" 
value="<%= Html.Encode( person.first_name ) %>" />
+3  A: 

You should Html.Encode else a " in the field could lead to injection problems

AnthonyWJones
+1  A: 

If you want to set a default value for an HTML element, you have to encode the HTML special characters inside the value using character references.

Gumbo