8

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 ) %>" />

2 Answers 2

6

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

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

Comments

1

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.

2 Comments

Gumbo can u please go to chat I have small question regarding this answer of yours
Hi. sorry . waited long time :-) can u please try again ? I'll wait.

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.