Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NET MVC ÈëÃÅ

ViewDataÓÐÒ»¸öModelStateµÄÊôÐÔ£¬ÕâÊÇÒ»¸öÀàÐÍΪModelStateDictionaryµÄModelStateÀàÐ͵Ä×ֵ伯ºÏ¡£ÔÚ½øÐÐÊý¾ÝÑéÖ¤µÄʱºòÕâ¸öÊôÐÔÊDZȽÏÓÐÓõġ£ÔÚʹÓÃHtml.ValidationMessage()µÄʱºò£¬¾ÍÊÇ´ÓViewData.ModelStateÖмì²âÊÇ·ñÓÐÖ¸¶¨µÄKEY£¬Èç¹û´æÔÚ£¬¾ÍÌáʾ´íÎóÐÅÏ¢¡£ÀýÈçÔÚǰһƪÎÄÕÂASP.NET MVC ÈëÃÅ7¡¢HellperÓëÊý¾ÝµÄÌá½»Óë°ó¶¨ÖÐʹÓõ½µÄUpdateModel·½·¨£º

ÎÒÃÇÔÚViewÖÐʹÓÃHtml.ValidationMessage(string modelName)À´¶ÔÖ¸¶¨µÄÊôÐÔ½øÐÐÑéÖ¤£º

Html.ValidationMessage()Óм¸¸öÖØÔØ£º
ÆäÖÐValidationSummary()ÊÇÓÃÓÚÏÔʾȫ²¿µÄÑéÖ¤ÐÅÏ¢µÄ¡£¸úASP.NETÀïÃæµÄValidationSummaryÑéÖ¤¿Ø¼þ²î²»¶à¡£
ÎÒÃDzâÊÔÒ»ÏÂ/Admin/SettingÒ³Ã棺

ÔÚÓÃUpdateModel·½·¨¸üÐÂBlogSettings.Instance.PostsPerPageµÄʱºò£¬µ±ÎÒÃÇÈçͼËùʾÌîд"10d"µÄʱºò£¬ÓÉÓÚPostsPerPageΪÕûÐ͵ģ¬ËùÒÔUpdateModel·½·¨¾Í»á³ö´í£¬Í¬Ê±»áÍùViewData.ModelStateÌí¼ÓÏàÓ¦µÄ´íÎóÐÅÏ¢£¬´Ó¶øHtml.ValidationMessage()·½·¨¾Í¿ÉÒÔ´ÓViewData.ModelStateÖмì²âµ½´íÎó²¢Ìáʾ¡£Í¬Ê±Html.ValidationMessage()·½·¨»áΪ³ö´íµÄÊôÐÔµÄÊäÈë¿òÌí¼ÓÒ»¸öÃûΪ"input-validation-error"µÄCSSÀ࣬ͬʱºóÃæµÄÌáʾÐÅÏ¢µÄCSSÀàÃûΪ"field-validation-error"£º

CSSÀàµÄÑùʽÊÇ¿ÉÒÔÓÉÎÒÃÇ×Ô¼º×ÔÓɶ¨ÒåµÄ¡£ÈçÉÏͼµÄºìÉ«¸ßÁÁÏÔʾ¡£
ºÃ£¬ÏÂÃæÎÒÃÇÀ´ÊµÏÖ·¢±íÐÂËæ±ÊµÄ¹¦ÄÜ¡£ÎÒÃÇÏÈдһ¸öÌṩÓû§ÊäÈëËæ±ÊÄÚÈÝµÄ±íµ¥Ò³Ã棺
<p>
    <label for="Title">±êÌâ</label>
    <%=Html.TextBox("Title", new { id = "Title", @class = "required" })%>
    <%=Html.ValidationMessage("Title")%>
</p>
<p>
    <label for="Content">ÄÚÈÝ</label>
    <%=Html.TextArea("Content")%>
    <%=Html.ValidationMessage("Content")%>
</p>
<p>
    <label for="Slug">URLµØÖ·±ðÃû(Èç¹ûΪ¿ÕÔòºÍ±êÌâͬÃû)</label>
    <%=Html.TextBox("Slug", new { id = "Slug", @class = "required" })%>
    <%=Html.ValidationMessage("Slug")%>
</p> 
 
È»ºóÎÒÃǶÔÓû§Ìá½»¹ýÀ´µÄÊý¾Ý½øÐб£´æ£º
[AcceptVerbs("PO


Ïà¹ØÎĵµ£º

ÿÌ춨ʱִÐÐÒ³Ãæ³ÌÐò(asp.net)

Ê×ÏȽ¨Á¢Ò»¸öc/s³ÌÐò ÔÚн¨µÄformÉϼÓÈëÒ»¸öä¯ÀÀÆ÷¿Ø¼þºÍÒ»¸öʱ¼ä¿Ø¼þä¯ÀÀÆ÷¿Ø¼þÄÜתÏòÄãÒªÖ´ÐеÄÒ³Ãæ¶øʱ¼ä¿Ø¼þ¿ØÖƶàÉÙʱ¼äºó¹Ø±ÕÄãÒªÖ´ÐеÄÒ³ÃæÈ»ºóÉèÖÃformµÄvisibleΪfalse formµÄ״̬Ϊ×îС»¯ Ä¿µÄÊǽ«Õû¸öÖ´ÐеÄÒ³Ãæ³ÌÐò°üÔÚformµÄä¯ÀÀÆ÷¿Ø¼þÖÐÖ´Ðжøform»á±»Òþ²Ø ÕâÑù×öÉñ²»Öª¹í²»¾õ¡£×îºóÓÃwindowsµÄ¼Æ»®ÈÎÎñÿÌì ......

asp.net µ÷Óô洢¹ý³Ì

1.»ñÈ¡Return·µ»ØÖµ
 ³ÌÐò´úÂë//´æ´¢¹ý³Ì
//Create PROCEDURE MYSQL
//     @a int,
//     @b int
//AS
//     return @a + @b
//GO
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToStri ......

ASP.NET²Ù×÷Cookie

//´´½¨
HttpCookie cookie = new HttpCookie("user","111");//´´½¨Cookie
cookie Expires = DateTime.Now.Add(15);//ÉèÖùýÆÚʱ¼ä
 Response.Cookies.Add(cookie);//´æÈë¿Í»§¶Ë
ÎÒÃÇÈ¡³öCookieÖµÒ²ºÜ¼òµ¥
string value = Request.Cookies["user"].value;
ÓÐʱºòÎÒÃÇÏëÔÚÒ»¸öCookieÖд¢´æ¶à¸öÐÅÏ¢£¬ÄÇÒ ......

ASP.NET ״̬·þÎñ ¼° session¶ªÊ§ÎÊÌâ½â¾ö·½°¸×ܽá

 
asp.net SessionµÄʵÏÖ£º
asp.netµÄSessionÊÇ»ùÓÚHttpModule¼¼Êõ×öµÄ£¬HttpModule¿ÉÒÔÔÚÇëÇó±»´¦Àí֮ǰ£¬¶ÔÇëÇó½øÐÐ״̬¿ØÖÆ£¬ÓÉÓÚSession±¾Éí¾ÍÊÇÓÃÀ´×ö״̬ά»¤µÄ£¬Òò´ËÓÃHttpModule×öSessionÊÇÔÙºÏÊʲ»¹ýÁË¡£
ASP.NETÖÐSessionµÄ״̬±£³Ö·½Ê½
ASP.NETÌṩÁËSession¶ÔÏ󣬴ӶøÔÊÐí³ÌÐòԱʶ±ð¡¢´æ´¢ºÍ´¦Àíͬһ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ