September 23, 2011

ASP.NET MVC: Razor


ASP.NET MVC 3 Razor

Version: 1.1.0

รายละเอียด

ASP.NET MVC 3 ได้แนะนำ view engine ใหม่ชื่อ Razor, เป็นสิ่งทีมีความเข้าใจและทำให้ง่ายขึ้นจาก syntax ปัจจุบันที่ใช้อยู่คือ ASP.NET web page. ใน Lab นี้ คุณจะได้เรียนวิธีการสร้าง Razor view ภายใน MVC solution. ในการเริ่มต้นของ Lab คุณจะมีความคุ้นเคยกับ Razor syntax และความสามารถของมัน, ในแบบฝึกหัดที่ 2 คุณจะเพิ่ม Razor view ใน MVC Music Store solution ที่สร้างมาให้มีการทำงานเหมือนกับคุณทำงานกับ ASP.NET view, แต่เข้าใจง่ายกว่าและโค้ดที่สั้นกว่า. และที่ Lab สุดท้าย ในแบบฝึกหัดที่ 3, คุณจะเรียนรู้วิธีการสร้างและการเรียกใช้วาน Third party ของ Razor Helpers.

คำอธิบายแบบคร่าวๆ

บันทึก:
ใน Lab นี้ คิดว่าคุณมีความรู้พื้นฐานเดียวกับ ASP.NET MVC. ถ้าคุณไม่เคยใช้ ASP.NET MVC มาก่อน, เราแนะนำให้คุณไปดู ASP.NET MVC Fundamentals Hand-on Lab.
ASP.NET MVC 3 เพิ่ม view engine ใช่ชื่อ Razor, ซึ่งเป็นสิ่งที่ง่ายต่อการเข้าใจจาก syntax ที่ใช้อยู่ในปัจจุบันของ ASP.NET web pages. ใน Lab นี้, คุณจะได้เรียนรู้วิธีสร้าง Razor views ภายใน MVC solution.

September 22, 2011

ASP.NET MVC: View Engine


ASP.NET MVC View Engines (Community Wiki)

Since a comprehensive list does not appear exist, let's start one here on SO. This can be of great value to the ASP.NET MVC community if people add their experience (esp. anyone who contributed to one of these). Anything implementing IViewEngine (e.g. VirtualPathProviderViewEngine) is fair game here. Just alphabetize new View Engines (leaving WebFormViewEngine at the top), and try to be objective in comparisons.

Design Goals:
A view engine that is used to render a Web Forms page to the response.
Pros:
  • ubiquitous since it ships with ASP.NET MVC
  • familiar experience for ASP.NET developers
  • IntelliSense
  • can choose any language with a CodeDom provider (e.g. C#, VB.NET, F#, Boo, Nemerle)
  • on-demand compilation or precompiled views
Cons:
  • usage is confused by existence of "classic ASP.NET" patterns which no longer apply in MVC (e.g. ViewState PostBack)
  • can contribute to anti-pattern of "tag soup"
  • code-block syntax and strong-typing can get in the way
  • IntelliSense enforces style not always appropriate for inline code blocks
  • can be noisy when designing simple templates
Example:
<%@ Control Inherits="System.Web.Mvc.ViewPage<IEnumerable<Product>>" %><% if(model.Any()) { %><ul>
    <% foreach(var p in model){%>
    <li><%=p.Name%></li>
    <%}%></ul>
<%}else{%>
    <p>No products available</p>
<%}%>



September 21, 2011

Why use ASP.NET MVC?

ทำไมต้อง ASP.NET MVC? :

      ASP.NET MVC (ปัจจุบัน กันยายน 2554 เวอร์ชั่น3) คือ Framework ที่ต่อขยายขึ้นมาจาก ASP.NET โดยพัฒนาบนมาตรฐาน web applications ที่ใช้ Design patterns เป็นที่ยอมรับ Module View Control (MVC) ร่วมกับการทำงานของ ASP.NET และ .NET Framework.

คุณสมบัติเด่น
- มีการรวม Scaffolding system extensible อย่าง NuGet เข้าไป
- HTML 5 ถูกเพิ่มเข้าไปใน project templates.
- Expressive View มีการเพิ่มView Engine ตัวใหม่อย่าง Razor.
- เต็มประสิทธภาพกับ Dependency Injection และ Global Action Filters.
- รองรับ Rich JavaScript กับ unobtrusive JavaScript, jQuery Validation และ JSON binding

September 10, 2011

Why use Microsoft!?

ทำไมต้อง Microsoft!?

     Microsoft(.Net[C#,VB,C++, ...), Sun Oracle (Java), IBM(SA...), SAP(ABAP), Adobe(Action Script) และ อื่น ๆ ( C++, PHP, Ruby, Python and so on.)

     การที่กล่าวว่าภาษาหนึ่งดีกว่าภาษาหนึ่งนั้นผมว่าไม่สมควรเพราะแต่ละภาษามีข้อมีข้อด้อยของตัวเองหรือเรียกกว่าเอกลักษณ์ของตัวเอง บางภาษาเหมาะกับงานที่ต้องติดต่อกับ Hardware ต้องการการทำงานที่เฉพาะเจาะจง บางภาษาใช้งานบนเครื่องเครื่องนั้น บางภาษาทำงานบนเว็บ บางภาษาใช้ส่งผ่านข้อมูล ซึ่งก็ขึ้นอยู่กับงานของคุณว่าเป็นงานประเภทไหนเหมาะสมกับภาษาอะไร และสามารถรับค่าใช้จ่ายได้มากแค่ไหน