Spark View Engine Html.TextArea Error?

I have a strange one. I am trying to render a standard text area simply using the TextArea helper:

    <p>
        <label for="Message">Message:</label>
        ${ Html.TextArea("IssueText") }
        ${ Html.ValidationMessage("IssueText", "*") }
    </p>

And my controller

   public ActionResult Contact() {
            return View();
    }
  [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Contact(FormCollection form) {
            Seller user = _session.AuthenticatedSeller;
            ServiceTicket ticket = new ServiceTicket(user, form["IssueText"],
               form["ContactReason"]);
            if (ticket.IsValid) {
                _servicetTicketRepository.Add(ticket);
                _servicetTicketRepository.Commit();
                return RedirectToAction("Index", "MyPlace");
            }

            ModelState.AddModelErrors(ticket.GetRuleViolations());
            return View();
        }

And the first time the page loads, it works fine and displays a text box

Until http://cadred.net/personal/contact-before.png

However, when I submit the form for validation validation, it no longer displays the text area

After http://cadred.net/personal/contact-after.png

+3
source share
1 answer

The reason you get the spark code instead of the test area is caused by the null ref exception that occurs when you try to execute html.textarea related statements.

, , .

<p>
  <label for="Message">Message:</label>
# System.Diagnostics.Debugger.Break();
  ${ Html.TextArea("IssueText") }
  ${ Html.ValidationMessage("IssueText", "*") }
</p>

F5 , , , ( ) ( , submit). VS, , .

, try catch, catch . , , , .

+3

Source: https://habr.com/ru/post/1719316/


All Articles