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

ASP.NET MVC ÈëÃÅ5¡¢ViewÓëViewData

±¾ÏµÁÐÎÄÕ»ùÓÚASP.NET MVC Preview5.
viewÔÚMVCģʽÖÐÓëÓû§½øÐÐ×îÖ±½ÓµÄ½Ó´¥£¬Ëü¸ºÔðÊý¾ÝµÄ³ÊÏÖ¡£ÕâÀïҪעÒâÒ»µã¾ÍÊÇ£¬viewÖ»ÊǸºÔðÊý¾ÝµÄ³ÊÏÖ£¬ËùÒÔÎÒÃÇÓ¦¸ÃÒª¾¡Á¿ÈÃ
viewÖв»Éæ¼°ÒµÎñÂß¼­µÄ´¦Àí¡£
ÎÒÃÇÀ´Ìí¼ÓÒ»¸öBlogÊ×Ò³µÄview¡£ÔÚ°²×°ÁËASP.NET MVCºó£¬ÎÒÃÇÔÚÌí¼ÓÐÂÏîÄ¿µÄʱºò¿ÉÒÔ¿´µ½ÓÐMVCµÄviewÄ£°å£º
 
×¢£ºÈç¹ûÄãµÄÊÇÖÐÎÄ°æ
µÄVS£¬°²×°Íêºó¿ÉÄÜ»á³öÏÖÕÒ²»µ½Õâ¸öÄ£°åµÄÏÖÏó£¬Äã¿ÉÒԲο¼
ÔÚÖÐÎÄ°æVS 08Öа²×°MVC
Õâƪ
ÎÄÕÂÉèÖÃһϡ£
ÆäÖÐMVC View Content PageÊÇÓÐĸ°æÒ³µÄ¡£ÎÒÃÇÔÚViews/HomeĿ¼ÏÂÌí¼ÓÒ»¸öMVC View Content
Page£¬²¢Ñ¡ÔñÎÒÃÇViews/SharedĿ¼ÏµÄSite.Masterĸ°æÒ³£º
public
 
partial
 
class
Index : ViewPage
{
}
ASP.NET
MVCĬÈÏÊÇʹÓÃWebFormÀ´×÷ΪviewµÄ¡£ËùÒÔÎÒÃÇ¿´µ½Ð½¨µÄaspxÒ³Ãæ¼Ì³Ð×ÔViewPage£¬Èç¹ûʹÓÃaspxÒ³Ãæ×÷ΪASP.NET
MVCµÄÊÓͼÒýÇ棬ÔòËùÓеÄaspxÒ³Ã涼±ØÐë¼Ì³Ð×ÔViewPage¡£ÎÒÃÇÔÙ¿´Ò»ÏÂViewPage£º

ÎÒÃÇ¿´µ½ViewPage¼Ì³Ð×ÔASP.NET
WebFormµÄPageÒ³£¬»¹ÊµÏÖÁËIViewDataContainer½Ó¿Ú£¬Í¬Ê±»¹ÌṩÁËһЩHelperÀàµÄʵÀý¡£ÎÒÃÇ¿ÉÒÔʹÓÃViewData
À´´ÓControllerÖÐÍùviewÒ³ÃæÖд«µÝÊý¾Ý¡£ÏÂÃæÎÒÃÇÔÚHomeControllerÖеÄIndex
ActionÖÐÈ¡³öPostsÁÐ±í£¬È»ºóÔÚViewÖÐÏÔʾ¡£ÎÒÃÇÏÈÔÚControllerÖÐÈ¡³öÊý¾Ý£¬Ç°Ãæ˵¹ý£¬ÎªÁË·½±ã£¬ÎÒÃÇ»áÖ±½ÓʹÓÃ
BlogEngineµÄModel²ãÀ´×÷ΪÎÒÃÇÕâ¸ö4mvcBlogµÄModel¡£ËùÒÔÎÒÃǵĴúÂëÈçÏ£º
public
ActionResult Index(
int
?
id)
{
    ViewData[
"
Title
"
]
=
BlogSettings.Instance.Name;
    List
<
IPublishable
>
posts
=
BlogEngine.Core.Post.Posts
       
.ConvertAll(
new
Converter
<
Post,
IPublishable
>
(
delegate
(Post p) {
return
p
as
IPublishable; }));
   
int
pageIndex
=
(id
!=
 
null
 
&&
id.HasValue
&&

id.Value
>
 
0
)
?
id.Value :
1
;
   
int
pageSize
=
Math.Min(posts.Count, BlogSettings.Instance.PostsPerPage);
   
if
((pageIndex
-
 
1
)
*
pageSize
+
pageSize
>
posts


Ïà¹ØÎĵµ£º

asp.netÁбíÊý¾ÝÏÔʾ+·ÖÒ³

һλCSDNÍøÓÑ·ÅÔÚÏÂÔØÀïµÄ
/////////////////
/// <summary>
/// ·ÖÒ³º¯Êý
/// </summary>
/// <param name="dtRecord">Êý¾ÝÔ´</param>
private void SplitPage(DataTable dtRecord) ......

asp.net DateTime ʱ¼äº¯Êý

1¡¢DateTime     Êý×ÖÐÍ   
    System.DateTime currentTime=new System.DateTime();   
    1.1 È¡µ±Ç°ÄêÔÂÈÕʱ·ÖÃë   
    currentTime=System.DateTime.Now;   
  & ......

Asp.Net´óÐÍÏîĿʵ¼ù ¹Ø¼ü¼¼Êõ·½°¸Ñ¡ÔñÀíÓɼ°Ë¼Â·

ËäÈ»ÎÒ²»Ï²»¶ÌÖÂÛÌ«¶àÀíÂÛ¸ÅÄîÉϵĶ«Î÷£¬µ«¸÷λ“ש¼Ò”»¹ÊÇÌá³öÁ˺ܶà·Ç³£ÓÐÕë¶ÔÐÔµÄÒâ¼û£¬Íû´ËÌû²»Òª³ÉΪ¿Úˮս²ÅºÃ....ÏÖ´ðÒÉÈçÏ£¨Óкܶà¸öÈËÀí½â£¬²»Ò»¶¨ÕýÈ·£©£º
ש¼ÒÒâ¼ûÇë²Î¼û£ºAsp.Net´óÐÍÏîĿʵ¼ùϵÁе¼º½
ΪʲôѡÔñNHibernate
ÀíÓÉ1£º¶ÔÏó¹ØϵӳÉä¼¼Êõ£¨ORM£©µÄ×îÖ÷ҪĿµÄÊÇΪÁ˽â¾ö¹ØϵÐÍÊý¾Ý¿âÓ ......

ASP.NET²¥·ÅÊÓƵÎļþ

///C#ÖеÄýÌå²¥·ÅÀà
using System;
namespace ConfigTools
{
/// <summary>
/// PlayClass µÄժҪ˵Ã÷¡£
///Ô­×÷CSDN,¾­±¾ÈËÉÔ¼ÓÐÞ¸Ä
/// </summary>
public class PlayClass
{
public PlayClass()
{
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ