asp.net mvc¿ò¼ÜÖÐjsonÐòÁл¯µÄ¿ØÖÆ
ÏÈ¿´ÏÂÃæµÄÒ»¶Î´úÂ룺
public class UserTest
{
public int age { set; get;
}
¡¡¡¡¡¡¡¡ public string name { set; get; } }
ÕâÊÇ×¼±¸ jsonÐòÁл¯µÄÀ࣬ÓÃmvc¿ò¼ÜÌṩµÄjson·½·¨£¬ºÜ¿ì¾Í¿ÉÒÔÍê³É£¬´úÂëÈçÏ£º
public ActionResult TestAjax(int? page)
{
UserTest test = new UserTest() { age = 20, name = "aa" };
return
Json(test)
}
ÏÖÔÚÎÊÌâÊÇÒª¿ØÖÆÐòÁл¯µÄÊôÐÔ£¬±ÈÈç˵ÏëÈÃnameÐòÁл¯£¬age²»ÐòÁл¯£¬ÈçºÎ×öµ½¡£
NonSerializedºÍXmlIgnore¶¼²»¿ÉÒÔ¡£ÓÖÊÔÁËÏÂÓÃ[DataContract]Ò²²»¿ÉÒÔ£¬Í»È»Ï뵽Ϊʲô²»¿´¿´jsonʵÏÖµÄÔ´ÂëÁË£¬´ò¿ªmvc¿ò¼ÜÔ´Â룬ÕÒµ½json·½·¨µÄÔ´ÂëÈçÏ£º
public override void ExecuteResult(ControllerContext context)
{
if (context == null) {
throw new
ArgumentNullException("context");
}
HttpResponseBase response = context.HttpContext.Response;
if
(!String.IsNullOrEmpty(ContentType)) {
response.ContentType =
ContentType;
}
else {
r
Ïà¹ØÎĵµ£º
ASP.NetÓÖ½ÐASP+
£±¡¢ÏµÍ³ÒªÇó
=====================
· CPU: Intel Pentium II-class 300 MHz (Intel Pentium III-class 600 MHz recommended)
· RAM: 96 MB (128 MB recommended)
· Available hard disk space (for install): 250 MB
· Available hard disk space (post install) ......
ÑéÖ¤¿Ø¼þÓÃÓÚÑéÖ¤Óû§µÄÊäÈ룬ÀûÓÃÕâЩ¿Ø¼þ£¬¿ª·¢ÈËÔ±¿ÉÒÔÇáËɵÄʵÏÖ¶ÔÓû§ÊäÈëµÄÑéÖ¤¡£ASP.NETÌṩÁËÁùÖÖÑéÖ¤¿Ø¼þ¡£
1.Required Field Validator£ºÑéÖ¤ÊäÈëÊÇ·ñΪ¿ÕµÄ¿Ø¼þ¡£
Ö÷ÒªÊôÐÔ£º
Control To Validate£º±íʾҪ½øÐмì²éµÄ¿Ø¼þID¡£´ËÊôÐÔ±ØÐëÉèÖÃΪÊäÈë¿Ø¼þµÄID£¬·ñÔò»á·¢ÉúÒì³£¡£ÁíÍâ¸ÃIDËù´ú±íµÄ¿Ø¼þ± ......
asp.net±¾ÉíÌṩÁËºÜ¶à¿Ø¼þ,Ìṩ¸øÎÒÃÇÕâЩ±È½ÏÀÁ¶èµÄÈËʹÓÃ,ÎÒÈÏΪ¿Ø¼þµÄ×÷ÓþÍÔÚ´Ë,ÒòΪÎÒÃDz»ÏëÖØ¸´¹¤×÷,ËùÒÔÒª´´½¨Ëü,Õâ¸ö±¾Éí±ãÊÇÒ»¸öÐèÇóµÄ¹ØÏµ,ËùÒÔѧϰ¿Ø¼þ¿ª·¢ºÜÓÐÒâ˼.
wroxÍøÕ¾ÉÏÓб¾Êé Professional ASP.NET 2.0 Server Control and Component Development
ÏÖÔÚ»¹Ã»Óгö°æ,µ«ÍøÕ¾ÉϷųöÁË´úÂë,ËùÒÔÕýºÃÏÂÔØ¹ý ......
¹ØÓÚÒ³Ãæ´«ÖµµÄ·½·¨£¬Òý·¢Á˺ܶàÌÖÂÛ¡£¿´À´ÓкܶàÈ˹Ø×¢Õâ¸ö£¬ÎÒ¾ÍÎÒ¸öÈ˹۵ã×öÁËЩ×ܽᣬϣÍû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1. ʹÓÃQueryString±äÁ¿
QueryStringÊÇÒ»Öַdz£¼òµ¥µÄ´«Öµ·½Ê½£¬Ëû¿ÉÒÔ½«´«Ë͵ÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖС£Èç¹ûÊÇ´«µÝÒ»¸ö»ò¶à¸ö°²È«ÐÔÒªÇ󲻸߻òÊǽṹ¼òµ¥µÄÊýֵʱ£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£µ«ÊǶÔÓÚ´«µ ......
page£ºpage¶ÔÏóÊÇÖ¸Ò³Ãæ×ÔÉíµÄ·½Ê½£¬ÔÚÕû¸öÒ³ÃæµÄÖ´ÐÐÆÚÄÚ£¬¶¼¿ÉÒÔÓøöÔÏó¡£
Request£º´Ë¶ÔÏó·â×°ÁËÓÉWebä¯ÀÀÆ÷»òÕ߯äËû¿Í»§¶ËÉú³ÉµÄHTTPÇëÇóµÄϸ½Ú£¬Ìṩ´Óä¯ÀÀÆ÷¶ÁÈ¡ÐÅÏ¢»òÕß¶ÁÈ¡¿Í»§¶ËÐÅÏ¢µÈ¹¦ÄÜ£¬ÓÃÓÚÒ³ÃæÇëÇóÆÚ¡£
Response£º´Ë¶ÔÏó·â×°ÁË·µ»Øµ½HTTP¿Í»§¶ËµÄÊä³ö£¬ÌṩÏòä¯ÀÀÆ÷Êä³öÐÅÏ¢»òÕß·¢ËÍÖ¸ÁÓÃÓÚÒ³ÃæµÄÖ´ÐÐ ......