I have a Html.TextBoxFor which I would like to assign some dynamic javascript to (the onchange event specifically):
@Html.TextBoxFor(model => answer.Value, new { @class = "answerinput", @onchange = "submitAnswer(\"" + Model.QuestionID.ToString() + "\")" });
However, when I examine the resulting HTML, the quotes around the value passed into the javascript function are encoded, which is a problem:
onchange="submitAnswer("3")"
I've tried a few things, like placing the string into an IHtmlString and then using the IHtmlString in the assignment but the results are always the same.
Is there a way to prevent MVC from encoding the value assigned to @onchange?
Thanks!