0

I am coding a C# MVC 5 internet application where a user enters XML input into a textbox in a view.

How can I encode this XML input as JSON when the view is posted?

Here is an example of the input:

<div class="form-group">
    @Html.LabelFor(model => model.data, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.data, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessage("data")
    </div>
</div>

Should the code to encode the value of the model.data input be in a javaScript onclick function, or somewhere else?

Simon
  • 7,991
  • 21
  • 83
  • 163

0 Answers0