Hello Guys ,
How is Your ride with asp.net mvc going ??
Let’s Understand the Views…
The set of views in an ASP.NET MVC application is the public face of the application. ASP.NET MVC views are responsible for rendering the HTML pages that people see when they visit your website.
Creating a View
The easiest way to create a new view is to create the view from an existing controller action. You can right-click anycontroller action within the Visual Studio Code Editor window and select the menu option Add View to create a new view automatically.
When you select the Add View menu option, the Add View dialog opens like below. This dialog enables you to set various view options. For example, you can specify whether a view uses a view master page.
For example, if you open a controller named Person and right-click the Index() action to add a view, and you leave the default options selected in the Add View dialog, you’ll get the view in like below Listing :
The above Listing looks almost like a standard HTML document. This view contains two <asp: Content> tags. Any content that you place within the first <asp: Content> tag appears in the <title> tag of the resulting HTML document. Any content that you place within the second <asp: Content> tag appears in the <body> tag of the resulting HTML document.
For example, the modified Index view in the below Listing has been modified to display the current time.
Above Listing contains familiar HTML tags such as the <h1 > and <p> tags. You can put anything that you would put in a normal HTML page within a view including images, iframes, Java applets, Flash, and Silverlight. The view also contains a script that displays the time. The expression DateTime. Now. ToString(“T”) returns the current time.
You embed a script in a view by using the <% %> script delimiters.The <%= %> script delimiters are shorthand for <% Response. Write %>. You can use the <%= %> script delimiters to write the value of an expression to the browser. The following two scripts do exactly the same thing:
<%= DateTime. Now. ToString(“T”) %>
<% Response.Write(DateTime. Now.ToString(“T”) ); %>
We’ll Understand view in detail in the upcoming posts….Till than Generate your simple views and enjoy Mvc’ing…
Hope this helps…