0
我目前拥有以下代码来编辑客户注释。ASP.NET MVC:服务器验证和返回视图时保持URL参数
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditNote(Note note)
{
if (ValidateNote(note))
{
_customerRepository.Save(note);
return RedirectToAction("Notes", "Customers", new { id = note.CustomerID.ToString() });
}
else
{
var _customer = _customerRepository.GetCustomer(new Customer() { CustomerID = Convert.ToInt32(note.CustomerID) });
var _notePriorities = _customerRepository.GetNotePriorities(new Paging(), new NotePriority() { NotePriorityActive = true });
IEnumerable<SelectListItem> _selectNotePriorities = from c in _notePriorities
select new SelectListItem
{
Text = c.NotePriorityName,
Value = c.NotePriorityID.ToString()
};
var viewState = new GenericViewState
{
Customer = _customer,
SelectNotePriorities = _selectNotePriorities
};
return View(viewState);
}
}
如果验证失败,我希望它再次渲染EditNote看法,但保存URL参数(NoteID和客户ID)这样的事情:“http://localhost:63137/Customers/EditNote/?NoteID=7&CustomerID=28”
任何关于如何做到这一点的想法?
谢谢!
你说得对。我的脑袋上放着一个屁。感谢给我我需要的火花。它现在正在通过这个表单,它正在工作。谢谢! – Mike 2010-01-28 17:31:18
优秀。乐意效劳。 – 2010-01-28 17:34:36