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