ASP.NET MVCÓëWebFormÇø±ð
[תÌùÒ»]
ʹÓÃASP.NET MVC¿ò¼Ü£¬´´½¨Ä¬ÈÏÏîÄ¿£¬µÚÒ»Ö±¹Û¸Ð¾õ¾ÍÊǵØÖ·¶¼ÊÇRewrite¹ýµÄ¡£¶ÔÔ´ÂëºÍÅäÖÃÎļþÉÔ¼Ó·ÖÎö²»ÄÑ¿´³ö£¬MVCʹÓÃÁËhttpModulesÀ´À¹½ØµØÖ·ÇëÇ󣬾ßÌåÓõ½ÁËSystem.Web.RoutingÀà¿â£¨MVC2ÖУ¬MVC1ÔõôÓõÄÍü¼ÇÁË¡££©¶øÕⲿ·ÖÀà¿â±»°ü×°ÔÚ.NET Framework3.5 SP1ÖУ¬MVC2ÐèÒªSP1Ö§³ÖÒ²¾ÍÀíËùµ±È»ÁË¡£SP1ÌṩµÄSystem.Web.RoutingÀà¿â¿ÉÒÔ·½±ãµØ½øÐеØÖ·ÇëÇóÀ¹½Ø£¬¶Ô±àÂë´¦Àí·½ÃæÒ²ºÜÓÅÐã¡£UrlRoutingModuleÀàÀ¹½ØÇëÇó£¬ÔÚÕâ֮ǰ£¬Application_StartµÄʱºò£¬»á¸øRouteTableµÄÈ«¾Ö¶ÔÏóÒ»¸öÀ¹½ØµÄÉèÖ᣶øÕâ¸öÉèÖÃʹÓÃRouteCollection¶ÔÏó½øÐб£´æ£¬MVC¶ÔÕâ¸öÀà½øÐÐÁËÀ©Õ¹——RouteCollectionExtensions¡£ÕâЩ¿ÉÒÔ²»¿¼ÂÇ£¬½ÓÏÂÀ´£¬µ±Óû§·ÃÎÊÒ³Ãæʱ£¬UrlRoutingModuleÀàÀ¹½ØÇëÇó£¬ÔÚRouteTableÖв鿴ÊÇ·ñ·ûºÏ¹æÔò£¬·ûºÏµÄ»°£¬¾Í»áµ÷ÓÃMvcHandler£¬Õâ¸öµ÷ÓÃÔÚhttpHandlersÅäÖýڵ㱻ע²á£¬Ìõ¼þÊǵØÖ··ûºÏ“*.mvc”¹æÔò¡£MvcHandlerµÄProcessRequest·½·¨¾Í»áµ÷ÓÃControllerÀ´Ö´ÐС£ÊÂʵÉÏÕû¸ö¹ý³Ì¶¼ÊǺںÐ×Ó£¬Óû§¸Ð¾õ²»µ½¡£ÔÚControllerÖÐij·½·¨Ö´Ðк󣬷µ»Ø½á¹û£¬ÔÙ½øÈë¾ßÌåµÄaspxÒ³Ãæ¡£
·ÖÎöÁËMVCµÄ¹¤×÷¹¤³Ì£¬¾Í¿ÉÒÔ¶Ô±ÈÆäÓëWebFormµÄÇø±ðÁË¡£ÎÒÃÇÖªµÀ£¬MVCģʽµÄÒµÎñ±»·ÅÖõ½ControllerÖÐÈ¥Ö´ÐУ¬¶øaspxÒ³ÃæÖ»¸ºÔðÏÔʾ¡£ÄÇôÔÚMVCÖеÄÒµÎñʵ¼ÊÖ´ÐÐʱ¼ä±»ÌáÇ°µ½ÁËHttpMoldeÖУ¬¶øWebFormµÄÇëÇóÖ»ÔÚhttpHandlerÈÝÆ÷Öб»Ö´ÐС£Ò²¾ÍÊÇ˵MVCÖÐControllerÓëViewµÄ·ÖÀëÊÇʹÓõÄASP.NetÇëÇó¹ÜµÀ¸ôÀëµÄ£¬ÕâÑùµÄ»°ÎÞÒÉÔÚ²»Ó°ÏìЧÂÊ£¨Ò»´ÎÇëÇ󣬶øResponse.RedirectÊǶþ´ÎÇëÇ󣩵ÄÇé¿öÏ´ï³ÉÁË´úÂëµÄÂß¼²ã´ÎµÄ·ÖÀë¡£
ͼ1 MVC¹¤×÷Ä£ÐÍ
MVC¹¤×÷µÄÓŵãÊÇÏÔÈ»µÄ£¬¸ü¼ÓÓÐÀûÓÚÀí½â·Ö²ãÂß¼£¬°ÑÎÕ´úÂëµÄ²ã´Î¸Ð¡£Controllerµ½aspxÒ³ÃæÖ®¼äµÄ¹ý³Ì£¬ÒѾ±»¿ò¼Ü¸ôÀë¡£ÖÁÓÚController»òÕßViewÒ³ÃæÓëModelµ÷ÓõĹý³Ì£¬»¹ÊÇÐèÒª×Ô¼ºÀ´°ÑÎÕ¡£ASP.NETµÄMVC¿ò¼ÜʵÏÖÁËController´úÂëµÄµ¥¶À¹ÜÀí¡£
¶ø¿´WebForm¿ª·¢Ä£ÐÍ£¬ÔòÖ»ÔÚHttpHandlerÈÝÆ÷ÖÐÖ´ÐУ¬¶ÔÆä½øÐзֲ㣬ÔÚ´óµÄ·½Ãæȱ·¦Ö§³Ö£¬¶øÖ»ÄÜÒÀ¿¿Âß¼ÉÏ·ÖÀë¡£²¢²»ÊDz»ÄÜ·ÖÀ룬¶øÊÇÓÉÒ»¶¨µÄ¾ÖÏÞÐÔ¡£HttpHandlerµÄÀ¹½Ø£¬ÊǸú·ÃÎʺó׺ÃûÓйصġ£µ±ÇëÇóÒ»¸öÒ³Ãæʱ£¬ÄǾÍÊÇÒ»¸öHandler£¬¶øWebFormÄ£ÐÍʵÏÖÏÔʾÓëÂß¼·ÖÀ룬²ÅÓеÄÊÇWinFormµÄʼþÇý¶¯¡£ÏÔÈ»£¬Ê¼þ±ØÐë±»×¢²áµ½Ò³ÃæÀ±ÈÈçButton1_ClickÕâÑùµÄ´úÂë¡£¶øÔÚButton1_ClickÖ´ÐÐ֮ǰ£¬Page_Load·½·¨»á±»Ö´ÐС£
ÏÔʾ´úÂ뱻дÈëPage_Loa
Ïà¹ØÎĵµ£º
·½·¨Ò»£º<asp:LinkButton runat="server" ID="lbtnClick" PostBackUrl='<%#"~/test.aspx?id="+Eval("id")%>'>zhang</asp:LinkButton>
·½·¨¶þ£º<asp:LinkButton runat="server" ID="lbtnClick" PostBackUrl='<%#Eval("id","~/test.aspx?id={0}")%>'>zhang</asp"LinkButton> ......
ÉÏ´ÎÎÒÃÇ˵µ½ÁË route ·ÓɵŦÄÜ,Õû¸ömvcÔËÐйý³Ì:
Route(·ÓÉ) --> Controller(¿ØÖÆÆ÷)-->action(·½·¨)
Õâ´ÎÎÒÃÇҪ˵µÄ¾ÍÊÇ controller ¿ØÖÆÆ÷ ºÍ action£º
¿ØÖÆÆ÷µÄ×÷ÓþÍÊÇ£ºµ±Ò»¸ö Request À´µÄʱºò£¬Ê×ÏÈRoute ½âÎö ÕÒµ½ÁË ¶ÔÓ¦ ¿ØÖÆÆ÷£¬¿ØÖÆÆ÷ÔÙ¸ù¾Ý action ¾ö¶¨¸øÎÒÃÇ·µ»ØʲôÑùµÄÄÚÈÝ¡£È磺
´úÂë ......
ÔÚ²¿ÊðË®¾§±¨±íʱÖ÷ÒªÓöµ½Ö§³Ö×é¼þµÄÎÊÌâ¡£
Ê×ÏÈ£¬ÐèÒªÔÚ·þÎñÆ÷ÉÏÐèÒª°²×°“CRRedist2008_x86.msi”ºÍºº»¯°ü“CRRedist2008_x86_chs.msi”¡£
vs.net 2008£¬ÔÚÕâ¸öĿ¼
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5
vs.net 2005£¬ÔÚÕâ¸öĿ¼
C:\Progr ......
Ê×ÏȽ¨Á¢¿Ø¼þGridView1£¬×¢ÒâàÞ
Ò³ÃæEnableEventValidation="false"±ØÐëµÄ¡£
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="P ......
ASP.Net ѧϰ֮·µ»ØÉÏÒ»Ò³µÄʵÏÖ·½·¨
[ÈÕÆÚ£º01-20] [×ÖÌ壺´ó ÖРС]
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔÀ´ÊäÈëµÄÊý¾Ý½øÐÐÐÞ¸ÄʱÓõģ¬»òÕßÊÇÒòΪÍøվΪÁË·½±ãä¯ÀÀÕ߶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.netÖж¼ÊÇÓÃÒ»¸öbuttonµÄ¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ ......