RSS

ASP.Net MVC 3 Razor View Quick Reference

01 Nov
  • @ : Identify Razor code segment.
  • @* *@ : Comment.
  • @( ) : Indicate pure server-side code. This is only in single line.
  • Razor supports if else, while, do while, and foreach statement
  • @{ } : Indicate code block. This can be written in multiple lines.
  • Code block is not purely server-side code, it can also contains client-side code (HTML).
  • In code block, HTML elements is required to indicate client-side content.
  • Use <text></text> element in code block to identify client-side text.
  • @model : Keyword to define a model.
  • @section : Keyword to render code / text to pre-defined section.
  • @helper : Keyword to define a helper which create a reusable code snippet.
  • @functions : Keyword to define a function which provides pure server-side methods that can be reused within the view.
  • @RenderBody() : Method to render all the content of the view. A placeholder for view’s entire content.
  • @RenderSection() : Method to define a region that content will be inserted into by consuming view.
Advertisements
 
Leave a comment

Posted by on November 1, 2011 in References

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: