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();
}
 
Ïà¹ØÎĵµ£º
ʹÓà ASP.NET UpdatePanel ¿Ø¼þ¿ÉÉú³É¹¦ÄܷḻµÄ¡¢ÒÔ¿Í»§¶ËΪÖÐÐÄµÄ Web Ó¦ÓóÌÐò¡£Í¨¹ýʹÓà UpdatePanel ¿Ø¼þ£¬¿ÉÒÔË¢ÐÂÒ³µÄÑ¡¶¨²¿·Ö£¬¶ø²»ÊÇʹÓûط¢Ë¢ÐÂÕû¸öÒ³Ãæ¡£Õâ³ÆΪִÐГ²¿·ÖÒ³¸üД¡£°üº¬Ò»¸ö ScriptManager ¿Ø¼þºÍÒ»¸ö»ò¶à¸ö UpdatePanel ¿Ø¼þµÄ ASP.NET ÍøÒ³¿É×Ô¶¯²ÎÓ벿·ÖÒ³¸üУ¬¶ø²»ÐèÒª×Ô¶¨Òå ......
3¸öÎļþ
code ÀàÎļþ
using System;
using System.Text;
namespace ConcreteMIS.Common.Chinese
{
/// <summary>
/// ºº×ÖÆ´ÒôÉùĸ¼ÆËãÀà
/// Write by WangZhenlong at 2003/11/29
/// </summary>
......
c#£¨»òvb.net£©³ÌÐò¸Ä½ø
1¡¢Ê¹ÓÃÖµÀàÐ͵ÄToString·½·¨
¡¡¡¡ÔÚÁ¬½Ó×Ö·û´®Ê±£¬¾³£Ê¹ÓÃ"+"ºÅÖ±½Ó½«Êý×ÖÌí¼Óµ½×Ö·û´®ÖС£ÕâÖÖ·½·¨ËäÈ»¼òµ¥£¬Ò²¿ÉÒԵõ½ÕýÈ·½á¹û£¬µ«ÊÇÓÉÓÚÉæ¼°µ½²»Í¬µÄÊý¾ÝÀàÐÍ£¬Êý×ÖÐèҪͨ¹ý×°Ïä²Ù×÷ת»¯ÎªÒýÓÃÀàÐͲſÉÒÔÌí¼Óµ½×Ö·û´®ÖС£µ«ÊÇ×°Ïä²Ù×÷¶ÔÐÔÄÜÓ°Ïì½Ï´ó£¬ÒòΪÔÚ½øÐÐÕâÀà´¦Àíʱ£¬½«ÔÚÍйܶÑÖÐ ......
¾³£ÒªÐ´Ò»Ð©.netµÄ³ÌÐò£¬¶ÔÓÚÊý¾Ý¿âµÄ·À×¢ÈëÒªÇóÒª±È½Ï¸ß¡£ÕâʱÎÒ´ÓÍøÉÏËÑÁËһЩ´úÂë¡£²é¿´ÁËÒ»ÏÂÖ÷ÒªÊÇͨ¹ýHTTPModelÀ´½øÐжԿͻ§¶Ëת¹ýÀ´µÄÊý¾Ý½øÐд¦Àí¡£
ÔÚ·þÎñÆ÷°²È«À¸Ä¿ÀïÎÒд¹ýһƪ¡¶ÆƽâͨÓÃSql·À×¢Èë·½·¨¡·µÄÎÄÕÂÖÐ˵µ½£¬Ò»Ð©Í¨ÓõķÀ×¢Èë·½·¨ÖÐûÓжÔcookieÊý¾Ý½øÐйýÂË£ ......
ÒªÏëÁ˽âasp.net 2.0µÄÒì²½Ò³µÄ´¦Àí¹ý³Ì,ÏÈÁгöÒ³ÃæµÄÉúÃüÖÜÆÚ£º
1 £ºInit ʼþ£º Ò³Ãæ³õʼ»¯ £¬³õʼ»¯ÉèÖá£
2£º LoadViewState·½·¨£º ¼ÓÔØÊÓͼ״̬£¬ Ìî³äViewStateÊôÐÔ¡£
3 £ºLoadPostData·½·¨£º ´¦Àí»Ø·¢Êý¾Ý£¬ ´¦Àí´«Èë´°ÌåÊý¾Ý¡£
4£º Load ʼþ£º ¼ÓÔØÒ³Ãæ £¬Ò³Ãæ¿Ø¼þ³õʼ»¯Íê³É²¢·´Ó³ÁË¿Í»§¶ËµÄÊý¾Ý¡£
5 £ºRa ......