У меня проблема с моим приложением ASP.NET, когда я пытаюсь передать строку из представления в контроллер ...
Мой контроллер (необходим метод)
`public ActionResult Mail(int id) //Display the View "Mail"
{
Customer customer = db.Customers.Find(id);
return View(customer);
}
[HttpPost,ActionName("Mail")] // this Method allow to send a email
public ActionResult MailConfirmed(int id)
{
Customer customer = db.Customers.Find(id);
string message = Request.Form.Get("messageBody");//Here I try to recuperate my messageBody
if(message!=null)
{
System.Diagnostics.Debug.WriteLine(message);
SendMail(customer.Mail, customer.Name, message);
return RedirectToAction("Index");
}
else
{
ModelState.AddModelError("", "Veuillez rentrer un message SVP");
}
return View(customer);
}`
Просмотр «Почты» (Страница, на которой менеджер может ввести тело сообщения и нажать «почта» для отправки сообщения)
'@using (Html.BeginForm())
{
<fieldset>
<legend>Customer</legend>
<div class="display-label">Pin</div>
<div class="display-field">
@Html.DisplayFor(model => model.Pin)
</div>
<div class="display-label">Name</div>
<div class="display-field">
@Html.DisplayFor(model => model.Name)
</div>
etc...
<div class="display-field">
@Html.TextBox("messageBody",null)//here the value that I try to pass in my controller
</div>
</fieldset>
}
@using (Html.BeginForm())
{
<p>
<input type="submit" value="Mail" />
<div>
@Html.ActionLink("Back to List", "Index")
</div>
</p>
}`
"сообщение" всегда пусто ... Можете ли вы помочь мне, пожалуйста?