[译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 1. Creating the Project 创建项目
来源:互联网 发布:淘宝网箱包类 编辑:程序博客网 时间:2024/05/21 17:49
Creating the Project 创建项目
To demonstrate the key jQuery features, we have created a simple MVC Framework application that lists mountain summits and their heights. Given that jQuery is a client-side technology, we will focus on the Razor view and HTML that this application generates. Listing 20-1 shows the view.
为了展示JQuery的关键特性,我们创建了一个列出山顶高度的简单MVC框架应用,鉴于JQuery是一个客户端技术,我们将重点放在Razor视图以及这个应用所生成的HTML上。清单20-1 展示了该视图:
清单 20-1. The Sample Application Index.cshtml View
@using MvcApp.Models; @model IEnumerable<Summit> @{ ViewBag.Title = "List of Summits"; } <h4>Summits</h4> <table> <thead> <tr><th>Name</th><th>Height</th><th></th></tr> </thead> @foreach (Summit s in Model) { <tr> <td>@s.Name</td> <td>@s.Height</td> <td> @using (Html.BeginForm("DeleteSummit", "Home")) { @Html.Hidden("name", @s.Name) <input type="submit" value="Delete" /> } </td> </tr> } </table> @Html.ActionLink("Add", "AddSummit") @using (Html.BeginForm("ResetSummits", "Home")) { <input type="submit" value="Reset" /> }
The view model for this view is a sequence of Summit objects, where the summit class has two properties: Name and Height. In the controller, we generate some example summits andpass them to the view, generating the HTML shown in Listing 20-2.
这个视图的View Model是一个Summit对象序列,Summit类包含两个属性:Name和Height。在控制器中,我们生成一些简单的summits对象并把他们传递给这个视图,清单20-2给出了生成的HTML代码。
清单 20-2. The HTML Generated by the Sample Application
<!DOCTYPE html> <html> <head> <title>List of Summits</title> <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script> </head> <body> <h4>Summits</h4> <table> <thead> <tr><th>Name</th><th>Height</th><th></th></tr> </thead> <tr> <td>Everest</td> <td>8848</td> <td> <form action="/Home/DeleteSummit" method="post"> <input id="name" name="name" type="hidden" value="Everest" /> <input type="submit" value="Delete" /> </form> </td> </tr> <tr> <td>Aconcagua</td> <td>6962</td> <td> <form action="/Home/DeleteSummit" method="post"> <input id="name" name="name" type="hidden" value="Aconcagua" /> <input type="submit" value="Delete" /> </form> </td> </tr> ...ommitted other summit tr elements... </table> <a href="/Home/AddSummit">Add</a> <form action="/Home/ResetSummits" method="post"> <input type="submit" value="Reset" /> </form> </body> </html>
We have omitted some of the table rows for clarity. Figure 20-1 shows how this HTML is displayed by the browser. We’ve switched away from the Visual Studio built-in browser for this chapter and used Internet Explorer 9 instead.
为了清晰起见,我们省略了表中的一些行。图20-1 展示了浏览器如何渲染这些HTML,在这章节,我们采用IE9替换VisualStudio内置的浏览器。
图20-1. The sample application HTML rendered by the browser
We know this looks pretty unpleasant, but bear with us. We’ll address some of the appearance issues as we explore the jQuery features.
我们可以看出这看起来让人相当不愉快,不过大家可以耐心等待,在我们探讨JQuery的特性的时候,我们会处理一些外观展示的问题。
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 1. Creating the Project 创建项目
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 2.Referencing jQuery 引用jQuery
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 3.Writing jQuery Code 编写jQuery代码
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition 目录及说明
- Programming ASP.NET, 3rd Edition
- 《Pro ASP.NET MVC 3 Framework》译文目录
- [翻译] Effective C++, 3rd Edition, Chapter 1. 习惯于 C++
- Apress.Pro.VB.2008.and.the.dot.NET.3.5.Platform.3rd.Edition.Mar.2008.eBook-BBL
- Contents of Programming ASP.NET 3rd Edition
- [翻译] Effective C++, 3rd Edition, Chapter 5. 实现
- C++ Programming Language, The (3rd Edition)
- Understanding the Linux Kernel, 3rd Edition
- Building the Data Warehouse (3rd Edition)
- The C# Programming Language (3rd Edition)
- Understanding the linux kernel 3rd edition
- Creating a Cascading Dropdown in ASP.net MVC 3 and jQuery (1)
- [翻译] Effective C++, 3rd Edition, Chapter 4. Designs(设计)和 Declarations(声明)
- [翻译] Effective C++, 3rd Edition, Chapter 3. Resource Management(资源管理)
- 概说概要设计怎么做
- 概要设计与详细设计的区别
- System.ArgumentException: 已添加项。字典中的关键字:“RegEx”所添加的关键字:“RegEx” 求解决 在线等!!!!
- 正则表达式的进阶
- Select函数实现原理分析(转载)
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 1. Creating the Project 创建项目
- module学习(11)
- module学习(10)
- Linux 下 Oracle随系统自动启动和关闭
- 根据地址由maps推算代码位置
- MSSQL分布式查询
- 收集的一些关于CMarkUp介绍
- ubuntu下启用,使用,修改Root密码
- Linux下NDK的安装配置