打印本文 打印本文 关闭窗口 关闭窗口
MVC模式在ASP.NET中的应用
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1783  更新时间:2009/4/23 10:50:18  文章录入:mintao  责任编辑:mintao
p;  //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}

以下是View2.aspx的原文件
----------------------

This page gets the result as a request parameter and displays it.

<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<script language="C#" runat="server">
 void Page_Load(Object sender, EventArgs e)
 {
  Label1.Text = Request.Params.Get("sum");   
 }
</script>
<html>
 <head>
  <title>View2</title>  
 </head>
 <body MS_POSITIONING="GridLayout">
  <h3>SUM</h3>
  <asp:Label id="Label1" Runat="server"></asp:Label>
  <form id="View2" method="post" runat="server">
  </form>
 </body>
</html>

结论
我希望这一个例子将会帮助你体会MVC模型的架构。这里提供的例子代码仅仅是演示如何实现这一模型架构, 而在实际的应用中通常会用一个配置文件来替换这个固定的GetServerPage(), 我之所以选择了这个只是为了保持代码的简洁。

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口