ASP.NET MVCÖеÄÑéÖ¤
1.¼òµ¥ÑéÖ¤
ÔÚASP.Net MVCÖУ¬ÑéÖ¤ÊÇÔÚController²ã£¬¶ø´íÎó³ÊÏÖÊÇÔÚView²ã£¬Controller²ãÊÇͨ¹ýModelStateÊôÐÔ½øÐÐÑéÖ¤µÄ,ModelStateµÄ״̬ÊÇͨ¹ýAddModelError()·½·¨½øÐÐ Ìí¼ÓµÄ¡£
¶øÔÚView²ã£¬ÊÇͨ¹ýHtmlµÄ¸¨Öú·½·¨½øÐгÊÏֵģ¬ÕâÁ½¸ö¸¨Öú·½·¨·Ö±ðÊÇ
Html.ValidationMessage()
Html.ValidationSummary()
Controller²ãµÄ¼òµ¥ÑéÖ¤
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Create([Bind(Exclude
=
"
CustomerId
"
)] Customer customer)
{
if
(customer.CompanyName.Length
==
0
)
{
ModelState.AddModelError(
"
CompanyName
"
,
"
CompanyName²»ÄÜΪ¿Õ
"
);
}
if
(customer.EmailAddress.Length
==
0
)
{
ModelState.AddModelError(
"
EmailAddress
"
,
"
EmailAddress²»ÄÜΪ¿Õ
"
);
}
if
(
!
ModelState.IsValid)
{
return
View();
}
 
Ïà¹ØÎĵµ£º
Ê×ÏÈÃèÊöÒ»ÏÂÎÊÌâ:ÒòΪ¿Í»§µÄÐèÒª,°ÑËùÓжÔÓÚÊý¾Ý¿âµÄ²Ù×÷×ö³ÉÁË´æ´¢¹ý³Ì,ͬʱҲ´æÔÚ´øÓÐÊäÈë²ÎÊýµÄ´æ´¢¹ý³Ì.¿Í»§ÒªÇó½«ËùÓеÄÐÅÏ¢¶¼¿ÉÒÔÓÃË®¾§±¨±íÏÔʾ.ÎÒÃǶ¼ÖªµÀ,ҪʹÓÃË®¾§±¨±íÎÒÃǾÍҪʹÓÃÊý¾ÝÔ´µÄ.ÔÚÕâÀï,ÎÒÃÇʹÓõÄÊý¾ÝÔ´×ÔÈ»¶øȻҲ¾ÍÊÇ´æ´¢¹ý³ÌÁË.µ±È»,ÎÒÃÇÒ²ÊÇÖªµÀµÄ,ÔÚADO.NETµÄÁ¬½ÓģʽÏÂ,Òª¸øË®¾§±¨±íÉèÖÃÊý¾ÝÔ ......
ÔÚ±¾ÑÝÁ·ÖУ¬½«Ê¹ÓÃÈý¸ö ASP.NET AJAX ·þÎñÆ÷¿Ø¼þ£¨ScriptManager ¿Ø¼þ¡¢UpdatePanel ¿Ø¼þºÍ Timer ¿Ø¼þ£©°´¹Ì¶¨µÄʱ¼ä¼ä¸ô¸üв¿·ÖÍøÒ³¡£Í¨¹ý½«ÕâЩ¿Ø¼þÌí¼Óµ½ÍøÒ³ÉÏ£¬¿ÉÏû³ýÔÚÿ´Î»Ø·¢Ê±Ë¢ÐÂÕû¸öÒ³ÃæµÄÐèÒª¡£½«Ö»Ðè¸üРUpdatePanel ¿Ø¼þµÄÄÚÈÝ¡£
1¡¢ÔÚ Microsoft Visual Studio 2005 ......
ÎÊÌâÃèÊö£º
Asp.NetÖÐdatalistµÈweb¿Ø¼þÀïÃ棬·Å¶à¸öµ¥Ñ¡°´Å¥µÄʱºò¿ÉÒÔͬʱ¶àÑ¡£¬¿ÉÒÔ²ÉÈ¡ÒÔÏ·ŷ¨¡£
ÎÊÌâ½â¾ö£º
×îÀíÏëµÄ½â¾öÖ®µÀ£¬ÓÃjavascript£º
<script language="javascript" type="text/javascript">
function clickit() {
var dom=document.all;
& ......
ÕâÀïÎÒÃǽ«½éÉÜASP.NET»º´æµÄ¹¤×÷ÔÀí£¬°üÀ¨¼òµ¥µÄ¶¨Ò壬Êý¾Ý»º´æÒÔ¼°»º´æµÄÉèÖõȵÈÄÚÈÝ¡£Ï£Íû±¾ÎÄÄܶԴó¼Ò½ñºóµÄ¹¤×÷ÓÐËù°ïÖú¡£
ÈçºÎ±ÜÃâASP.NET»º´æÕ¼ÓÃϵͳ×ÊÔ´
ÔÙ̸ASP.NET»º´æ»úÖÆ£º¿ª·¢Ð§ÂÊÓëÓÅ»¯µÄ..
ASP.NET»º´æ»úÖÆ»ù´¡¸ÅÄî
ASP.NET»º´æÊý¾ÝÌí¼Ó·½·¨Ò»ÀÀ
ASP.NET»º´æÊý¾Ý¼¼ÇÉÈýÔò
½éÉÜ
»º´æÊÇÔÚÄÚ´æ´ ......