Bài đăng

ASP.NET MVC 3: Layouts with Razor

http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx

Quick Start Guide RazorEngine

RazorEngine has been moved to Github  http://github.com/Antaris/RazorEngine Update - An early look at RazorEngine v3 New blog post - http://www.fidelitydesign.net/?p=473 Project Description A templating engine built upon Microsoft's Razor parsing technology. The RazorEngine allows you to use Razor syntax to build robust templates. Currently we have integrated the vanilla Html + Code support, but we hope to support other markup languages in future. Using the templating engine couldn't be easier, using a simple syntax, we can do the following: string template = "Hello @Model.Name! Welcome to Razor!" ; string result = Razor.Parse(template, new { Name = "World" }); The templating engine supports strict and anonymous types, as well as customised base templates, for instance: Razor.SetTemplateBase( typeof (HtmlTemplateBase<>)); string template = @"<html> &l

Tortoise SVN – My global ignore pattern (C# and R#)

Hình ảnh
Don’t know what I’m talking about? Read this . I’m tired of having to recreate this over and over again so I had to make a note somewhere. 1 *\bin* *\obj* *.suo *.user *.bak **.ReSharper** **\_ReSharper.** StyleCop.Cache Update Meanwhile I am maintaining ignore patterns for svn, git and hg here: https://github.com/lcorneliussen/xignore/ 1 .git target* *\bin *\bin\* *\obj *\obj\* *.suo *.user *.bak *.ReSharper** **\_ReSharper.** **\StyleCop.Cache **\*.dotCover *.releaseBackup release.properties *.versionsBackup *.diff *.vssscc *.vspscc *.scc About these ads Share this: Twitter Digg Print Email Related Recent publications In "Publikationen" My .NET Development Must-have Tool List In "Just Drops" How-to branch and patch SVN- or TFS/Codeplex-based open source projects with GIT (Part 1) In "Source Control" Posted in dotnet | Tagged R# , tortoisesvn | 8 Co

Output dữ liệu trong MVC

I. Trả về HTML bằng cách trả lại một view Một kiểu phản hồi phồ biến nhất của một action là tạo ra HTML và gửi nó về trình duyệt của người dùng. Khi chúng ta sử dụng hệ thống action result, chúng ta cần khởi tạo một đối tượng lớp ViewResult mà chúng ta muốn trả lại để tạo ra mã HTML như đoạn mã ví dụ sau 1 2 3 4 5 6 7 8 9 10 11 using System.Web.Mvc;   namespace ControllersAndActions.Controllers {        public class ExampleController : Controller {            public ViewResult Index() {              return View( "Homepage" );          }      } } Trong đoạn mã bên trên, chúng ta sử dụng phương View helper để tạo thể hiện của lớp ViewResult, cái mà sẽ được trả về như là kết quả của action method Chúng ta chỉ định view nào mà chúng ta muốn dùng bằng cách truyền tham số cho phương thức View. Ở đây, chúng ta dùng Homepage Chúng ta có thể tạo ra một đối tượng ViewResult một cách tường minh như đoạn mã sau: 1 2