asp.net 点滴事项
1、要进行跳转链接
@Html.ActionLink("Edit", "Edit", new { id=item.ID })
return RedirectToAction("Index");
2、可通过以下方式进行数据实体的验证
if (ModelState.IsValid)
3、如何给默认值
public ActionResult ssss(int id=0)
4、以下代码实现的是在clr中进行mapping的时候,找delete就找到deleteconfirmed
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id =0)
5、验证实例如下
[Required(ErrorMessage = "Title is required")]
public string Title { get; set; }
[Required(ErrorMessage = "Date is required")]
public DateTime ReleaseDate { get; set; }
[Required(ErrorMessage = "Genre must be specified")]
public string Genre { get; set; }
[Required(ErrorMessage = "Price Required")]
[Range(1, 100, ErrorMessage = "Price must be between $1 and $100")]
public decimal Price { get; set; }
[StringLength(5)]
public string Rating { get; set; }}
[Required(ErrorMessage = "Date is required")]
public DateTime ReleaseDate { get; set; }
[Required(ErrorMessage = "Genre must be specified")]
public string Genre { get; set; }
[Required(ErrorMessage = "Price Required")]
[Range(1, 100, ErrorMessage = "Price must be between $1 and $100")]
public decimal Price { get; set; }
[StringLength(5)]
public string Rating { get; set; }}
[DataType(DataType.Date)]
public DateTime ReleaseDate { get; set; }
[DataType(DataType.Currency)] public decimal Price { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
public DateTime ReleaseDate { get; set; }
//*********************************************************************//
ASP.NET MVC Tip #46 — Don't use Delete Links because they create Security Holes.