I'm still quite new to ASP.Net MVC, so maybe this is a stupid question.
I'm using MVC 3 with razor syntax.
My question is, how do I show some HTML after a successfull post ?
I've got a password recovery page, and upon posting correct information I'd like it to show the view again, but add a "A new password has been sent to your e-mail address" to it.
In WebForms I'd just have a invisible panel and show it, or a literal and stuff some text into it on postback. What do I do in MVC ?
I suppose I could add a different view for it, but really that seems a bit like overkill - or am I misunderstand the MVC paradigm here ?
EDIT:
I tried using the strongly typed model for this, but it doesn't work :-(
My view (simplified a bit):
@model BudgetPal.Model.MVC.Account.EditModel
@if (Model.ShowConfirmation)
{
<div class="confirmation">Your profile has been saved.</div>
}
The Model:
public class RecoverPasswordModel
{
[Required]
[Display(Name = "E-mail")]
[StringLength(250)]
[RegularExpression(@"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})", ErrorMessage = "Not a valid e-mail address")]
public string Email { get; set; }
public bool ShowConfirmation { get; set; }
}
And my controller:
public ActionResult Edit()
{
EditModel model = new EditModel(UserSession.User);
return View(model);
}
[HttpPost]
public ActionResult Edit(EditModel model)
{
if (!ModelState.IsValid)
return View(model);
// Save changes here
model.ShowConfirmation = true;
return View(model);
}