asp.net MVC2 初探二

news/2025/2/26 7:24:22
这一节我们看如何发布Asp.net MVC
在项目的引用中设置上面三个dll的copy local为true,然后在项目上点击右键publish,publish到一个目录下。这个和一般的wenForm页面一样。然后进行网站配置
 
确保这块是4.0,当然根据你装的.net版本,点击主目录
确保aspnet_isapi.dll要在目录中,如下
还有启用下面的选项
运行网站,如下,成功了。
下面是一个LINQ查询的示例
InBlock.gif using System; 
InBlock.gif using System.Collections.Generic; 
InBlock.gif using System.Linq; 
InBlock.gif using System.Web; 
InBlock.gif using System.Web.UI; 
InBlock.gif using System.Web.UI.WebControls; 
InBlock.gif 
InBlock.gif public partial  class _Default : System.Web.UI.Page 
InBlock.gif
InBlock.gif         protected  void Page_Load( object sender, EventArgs e) 
InBlock.gif        { 
InBlock.gif                 if (!IsPostBack) 
InBlock.gif                { 
InBlock.gif                        DataClassesDataContext dc =  new DataClassesDataContext(System.Configuration.ConfigurationManager.ConnectionStrings[ "MoviesConnectionString"].ToString()); 
InBlock.gif                         this.GridView1.DataSource = dc.Movies; 
InBlock.gif                         this.GridView1.DataBind(); 
InBlock.gif                         this.BindDropDowList(); 
InBlock.gif                } 
InBlock.gif                
InBlock.gif        } 
InBlock.gif         protected  void Button1_Click( object sender, EventArgs e) 
InBlock.gif        { 
InBlock.gif                IQueryable<Movy> Iquery= null
InBlock.gif                 int id =  int.Parse(DropDownList1.SelectedValue); 
InBlock.gif                 switch (id) 
InBlock.gif                { 
InBlock.gif                         case -1: 
InBlock.gif                                Iquery = from movie  in  new DataClassesDataContext().Movies select movie; 
InBlock.gif                                 break
InBlock.gif                         default
InBlock.gif                                Iquery = from movie  in  new DataClassesDataContext().Movies 
InBlock.gif                                                 where movie.ID == id 
InBlock.gif                                                 select movie; 
InBlock.gif                                 break
InBlock.gif                } 
InBlock.gif                 this.GridView1.DataSource = Iquery; 
InBlock.gif                 this.GridView1.DataBind(); 
InBlock.gif        } 
InBlock.gif 
InBlock.gif         protected  void BindDropDowList() 
InBlock.gif        { 
InBlock.gif                DataClassesDataContext dc =  new DataClassesDataContext(System.Configuration.ConfigurationManager.ConnectionStrings[ "MoviesConnectionString"].ToString()); 
InBlock.gif                 this.DropDownList1.DataSource = dc.Movies.ToList(); 
InBlock.gif                 this.DropDownList1.DataTextField =  "Movie_Name"
InBlock.gif                 this.DropDownList1.DataValueField =  "Id"
InBlock.gif                 this.DropDownList1.DataBind(); 
InBlock.gif                 this.DropDownList1.Items.Insert(0,  new ListItem( "全部""-1")); 
InBlock.gif        } 
InBlock.gif         protected  void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) 
InBlock.gif        { 
InBlock.gif                 if (e.Row.RowType == DataControlRowType.DataRow) 
InBlock.gif                { 
InBlock.gif                        e.Row.Attributes.Add( "onMouseOver""SetNewColor(this);"); 
InBlock.gif                        e.Row.Attributes.Add( "onMouseOut""SetOldColor(this);"); 
InBlock.gif                }        
InBlock.gif        } 
InBlock.gif
运行结果如下


本文转自 BruceAndLee 51CTO博客,原文链接:http://blog.51cto.com/leelei/317871,如需转载请自行联系原作者


http://www.niftyadmin.cn/n/710338.html

相关文章

有限元计算 求解笔记(下)

有限元计算原理 5. 实例问题 5.1 E是&#xff08;X&#xff0c;Y&#xff09;的函数 首先假设杨氏模量为常量E0&#xff0c;积分计算就是乘法&#xff1a; so 应变矩阵由节点坐标确定 单元刚度矩阵给出&#xff1a; 那么对于E为变量的情况&#xff0c;假设E的方程为 so…

centos使用yum安装软件的时候出现了undefined symbol: CRYPTO_set_locking_callback

1、问题 在CentOS下使用yum安装软件&#xff0c;结果出现了下面的错误提示&#xff1a; # yum installThere was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was: /usr/lib/python2.6/site-packages/pycurl.so: un…

V 7 keepalived+[nginx,haproxy]

环境&#xff1a; [rootnode1 ~]# uname -a Linux node1.magedu.com2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64GNU/Linux 准备&#xff1a; VIP&#xff08;192.168.41.222&#xff09; node1&#xff08;nginx|haproxy’s master&#…

ESP8266 调试记录

2019/12/21 时隔一年再次捡起ESP8266&#xff0c;希望在12月之前完成这部分通信吧。 暂时需要的功能&#xff1a; 用ESP8266代替Arduino上的数据线&#xff08;就这么简单 初步调试&#xff1a; 硬件接线&#xff1a; ESP8266 —— Arduino 3v3 —— 3.3V RX —— pin3…

2017年Linux运维人员必会开源运维工具体系

Linux运维人员必会开源运维工具体系 说明&#xff1a;不同的技术人员&#xff0c;在不同的阶段确定知识边界非常重要&#xff0c;否则&#xff0c;虽然是千里马&#xff0c;但是不知道终点在哪&#xff0c;最终累死也达不到目标。 例如&#xff1a;拿8K要学多少知识&#xff0c…

Transform.SetParent 笔记

refer to https://docs.unity3d.com/ScriptReference/Transform.SetParent.html 重感冒&#xff0c;只能摘抄两篇解闷。 1. 参数 parent 需要使用的parent转换。 worldPositionStays 【直译的话当然极其不通顺&#xff1a;世界坐标的停留】 如果为真&#xff0c;则修改pa…

数学建模模板

全国大学生数学建模竞赛就开始了&#xff0c;这里分享一下我自己的数学建模论文模板&#xff0c;写的不好&#xff0c;请指教&#xff1a; 论文标题 摘要 内容要点&#xff1a; 1、研究目的&#xff1a;本文研究问题。 2、建立模型思路&#xff1a;首先&#xff0c;本文。 然后…

GPG入门教程

原文地址&#xff1a;http://www.ruanyifeng.com/blog/2013/07/gpg.html 作者&#xff1a; 阮一峰 日期&#xff1a; 2013年7月12日 前两篇文章&#xff0c;我介绍了RSA算法。 今天&#xff0c;就接着来看&#xff0c;现实中怎么使用这个算法&#xff0c;对信息加密和解密。这要…