易截截图软件、单文件、免安装、纯绿色、仅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生成html静态页的两种方法~~~

第一种方法是对一个aspx页面生成html文件,先对服务器发送请求aspx页面,取服务器返回的html流,写到一个html文件里,aspx页面显示的是什么,生成的html页面就是什么
1、asp方法:
sub createHTML
  dim xmlhttp,strhtml,objAdoStream,i,myurl
  set xmlhttp=server.CreateObject("Microsoft.XMLHTTP")
&nb ......

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 文件下载

下载页面:
 <a href="download.ashx?url=<%=Server.UrlEncode("说明.txt")%>">下载</a>
------------------------------------------------------------------------------
download.ashx
<%@ WebHandler Language="C#" Class="download" %>
using System;
using System.Web;
public ......

asp.net客户端传递参数心得

 
客户端传送数据到服务器端有三种方法:
1.form
2.querystring
3.cookie
利用这些方式取得的数据在服务器端都是字典集合,如果要精确取到某个集合的值,则直接使用对应的集合的名称,三种方式对应的集合如下:
1.form:request.form
2.querystring:request.querystring
3.cookie:request.cookie
利用request.p ......

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号