Use the hidden field and set its value before the message. Just make sure it is inside your form.
@Html.HiddenFor(Model.data)
To set a value in javascript using jQuery:
$("#data").val('my big string');
Alternatively, if you are not attached to a strongly typed view, instead of @Html.HiddenFor() simple, hidden HTML code will work:
<input type="hidden" id="data" name="data" />
source share