Hi Friends
I am Vignesh, am new to MVC Technology. I started to learn MVC now and I have doubts in that,so guide me
I have VS 2010 professional and having MVC2 as default platform, my friend telling MVC 2 is not best as MVC3 because its having Razor Engine. Guide me which is best aspx engine or razor engine ?
In that HOw shoud I design a page in Both engines ?
Thanks
Vignesh
Rajeev KumarPosted Jul 11, 2023, 5:36 AM
Hello Vignesh,
MvC3 is a much better game than MvC2.
Sukesh MarlaPosted Aug 19, 2014, 12:49 AM
Ramesh MaruthiPosted Aug 17, 2014, 6:13 PM
We use HTML helpers to encapsulate some small HTML fragments which are repeated all over your pages. And to avoid writing those HTML snippets all over again you use helpers.
They are very useful, especially when dealing with things like URLs because instead of hardcoding your links helpers take advantage of routing the definition on your server and by simply changing those routes the whole site URLs' change without ever touching any single HTML page.
Another scenario where HTML helpers are useful is for generating form input fields. In this case they automatically could handle values when posting back and show associated validation messages. Can you imagine the spaghetti code you would have to write in your views if there weren't HTML helpers?
Please look at the below links
http://www.w3schools.com/aspnet/mvc_htmlhelpers.asp
http://www.dotnet-tricks.com/Tutorial/mvc/N50P050314-Understanding-HTML-Helpers-in-ASP.NET-MVC.html
Vignesh BabuPosted Aug 16, 2014, 2:21 AM
I know this answerbut plz explain the role of HTML HELPERS in this case.
Ramesh MaruthiPosted Aug 15, 2014, 12:31 PM
What is a View Engine
View Engines are responsible for rendering the HTML from your views to the browser. The view engine template will have different syntax for implementation. Currently there are few number of view engines available for MVC and the top four view engines are Razor, traditional ASPX, Spark and NHaml.
Razor
The Razor view engine is an advanced view engine from Microsoft, packaged with MVC 3. Razor using an @ character instead of aspx's <% %> and Razor does not require you to explicitly close the code-block, this view engine is parsed intelligently by the run-time to determine what is a presentation element and what is a code element.
In my opinion Razor is the best view engine available for MVC as its much cleaner and easy to write and read. This view engine is compatible with unit testing frameworks. It is very difficult to implement unit test with ASPX view engine. And other view engines doesn't provide anything related to testablity in their respective sites.
This is the default view engine in MVC 3 and MVC 4. Web pages with Razor syntax have the special file extension cshtml (Razor with C#) or vbhtml (Razor with VB).
Sample code is given below,
Collapse | Copy Code
Sample with Razor
Hello @name, the year is @DateTime.Now.Year
checkout this prodcut
ASPX
The syntax for writing views with this engine is the same syntax that the ASP.NET Web Forms uses and the file extensions are also taken from ASP.NET Web Form (.aspx, .ascx, .master) . The coding will give us the memory of legacy ASP style.
This is the default view engine for MVC 1 and MVC 2.
Sample code is given below,
Collapse | Copy Code
Sample with ASPX
Hello <%=name %>, the year is <%= DateTime.Now.Year %>
checkout this prodcut
Please look at this link :)
http://www.codeproject.com/Articles/534970/ASP-NET-MVC-Part-Razor-ASPX-View-Engine