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

ASP.NET MVC 2 Ä£°æÏµÁÐ2: ModelMetadata

ͬÑùÊÇһƪתÌûµÄÎÄÕÂ,
Ô­ÎÄ: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-2-modelmetadata.html 
×ÅÖØ½éÉÜÁËASP.NET MVC2 ÀïÃæµÄ ModelMetadata Àà
ASP.NET MVC 2 Templates, Part 2: ModelMetadata
Series Index
Part 1: Introduction
Part 2: ModelMetadata
Understanding Your Model
One
of the classes we introduced with ASP.NET MVC 2 is ModelMetadata. This
class is designed to tell you interesting things about the objects you
want to display or edit. While we commonly use them when writing
templates, this metadata is actually always available, even when you’re
not in a template.
What is a Model?
When it comes to ModelMetadata, the definition of “model” is probably a bit blurrier than you’re used to.
Let’s say for instance that you have the model from part 1 of this blog series:
view sourceprint?
1.public class Contact {
2.    public string FirstName { get; set; }
3.    public string LastName { get; set; }
4.    public int Age { get; set; }
5.}
You created a strongly-typed view for this model, and if inside the
view you access ViewData.ModelMetadata, then the model at this point is
the Contact object.
However, through this metadata object, you can also get metadata
about all of its properties. This returns a collection of ModelMetadata
objects, one for each of the properties. If we were to do this with our
Contact object, we’d end up with 3 new metadata objects, one each for
FirstName, LastName, and Age. When you’re looking at the model metadata
for FirstName, the model type is String (and the container type is
Contact). In this way, you can even recursively dive through several
layers of complex objects via properties.
How Do I Get One?
Use the one for the current model.
The most common way to get one is to access the
ModelMetadata property on ViewData as shown above. This metadata object
describes the ViewData&


Ïà¹ØÎĵµ£º

ASP.NET FileUploadÓ¦ÓÃʵÀý

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" & ......

¹ØÓÚasp.netµÄÅäÖÃÎļþ

ÅäÖÃÎļþ¿ÉÓÃÀ´´æ·ÅһЩ¶à´ÎÓõ½µÄ³£Á¿Êý¾Ý£¬ÈçÁ¬½Ó´®£º
<appSettings>
<add key="connStr1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="connStr2" value="App_Data\test.mdb"/>
</appSettings>
Õâ¸öÅäÖÃÊý¾Ý¿âÁ¬½Ó´®
ʹÓÃʾÀý£º
  public class DBCo ......

asp.netÓû§ASPNETµÇ¼ʧ°ÜµÄÎÊÌâ

¡¡Ö´Ðе±Ç° Web ÇëÇóÆÚ¼ä£¬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£
¡¡¡¡Òì³£ÏêϸÐÅÏ¢: System.Data.SqlClient.SqlException: Óû§ 'XXXASPNET' µÇ¼ʧ°Ü¡£
¡¡¡¡½ñÌì½«ÍøÕ¾Ç¨ÒÆ¹ýÀ´ºó,¾Í·¢ÏÖÕâ¸öÎÊÌâ.¾­¹ýÃþË÷,·¢ÏÖÔ­ÒòÊÇÎÒÃǵǼÊý¾Ý¿âµÄ½ÇÉ«¶ÔÊý¾Ý¿âµÄȨÏÞ²»¹». ......

ASP.NET Ò³ÃæÖ¸Áî Ö® @OutputCache

»º´æµÄÖØÒªÐԾͲ»ÓÃÔÙÇ¿µ÷ÁË£¬@OutputCache¸øÎÒÃÇÌṩÁËÒ»ÖÖÉùÃ÷µÄ·½Ê½(¶ÔÓ¦µÄ»¹Óбà³ÌµÄ·½Ê½)À´¿ØÖÆÒ³ÃæºÍÓû§¿Ø¼þµÄ»º´æ²ßÂÔ£¬ÕâÊÇÒ»ÖÖ×î¼òµ¥Ö±½ÓµÄÍøÕ¾ÓÅ»¯·½Ê½¡£
»¹ÊÇÏÈÀ´¹ýÒ»±é@OutpuCacheËùÓеÄÊôÐÔ£¬¹²ÓÃ11¸öÊôÐÔ£¬Õâ¸öÖ¸Áî¿ÉÒÔÓÃÓÚÒ³Ãæ(.aspx)ºÍÓû§¿Ø¼þ(.ascx)
ÊôÐÔ
Duration
Ò³»òÓû§¿Ø¼þ½øÐлº´æµÄʱ¼ä£¬µ¥Î ......

ASP.NET(C#) DataSetÊý¾Ýµ¼³öµ½Excel

½ñÌì¸ø¿Í»§×öÁ˸ö¹¦ÄÜÐèÒª°ÑÍø¸ñÊý¾Ý£¨Gridview£©µ¼³ö³ÉExecl£¬ËùÒÔÎÒÈ¥ÍøÉÏÕÒÁ˸ö´úÂë private void Export(string FileType, string FileName)
...{
try
...{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "att ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ