In this and future posts, we will go over a few ASP.NET MVC interview questions. Let’s tackle Razor engine in this post.
Question: What is Asp.Net MVC Razor?
Razor is the newest view engine released by Microsoft. It’s key features include optimized Html generation, easy to learn, compact, expressive and enabling a fluid coding workflow. The Razor syntax is a template markup syntax that enables you to use an HTML construction workflow. Instead of using the ASP.NET .ASPX markup syntax with
<%= %>
symbols to indicate code blocks, Razor syntax starts code blocks with a @ character and does not require explicit closing of the code-block.Question: How can you create a link to a JavaScript file in a view?
With MVC 4 release, the Razor engine has been updated to better serve files. Instead of having to use path mapping methods @Url.Content to render the content of the file, you can now render using the tilde ( ~ ) character as shown below:
<script src="~/Scripts/ref.js"></script>
Question: Display some content only if a certain property in the backing model is not null.
Many times, you have the situation where you need to change the CSS property for a certain block of text only if the backing model has that info. This relatively common feature can now be simply rendered by direct html binding as shown below:
<div class="@Model.HighlightImClass">@Model.UserIm</div>
Question: How can you set the checked state of input boxes based on backing model?
This is again similar in nature to the question above. You can directly bind boolean properties of the model to Html controls.
<input checked="@Model.IsFreeShipping" type="checkbox" />
Question: How can you use Razor to serve bundled CSS or JavaScript files?
In a nutshell? Very cleanly in an intuitive way. MVC 4 has a brand new syntax to serve bundled content as shown:
@Scripts.Render("~/Scripts/cart/js") @Styles.Render("~/Content/cart/css", "~/Content/order/css")
Good. Please add more. http://www.hoven.in
ReplyDeletehttp://www.hoven.in
Great, useful.
ReplyDeleteI found another great article describing new features of ASP.NET MVC 4 in form of interview questions.
http://jinaldesai.net/asp-net-mvc-4-new-features-interview-questions/
HTH!
great!!
ReplyDeleteGood one.
ReplyDeleteFor Top 10 ASP.NET MVC Interview Questions, please follow:
http://www.webdevelopmenthelp.net/2013/09/Top-ASP-NET-MVC-Interview-Questions.html
Nikhil Sir Please Add Other features like WCF,WPF,SHAREPOINT ETC. //////////////////////////////////////]
ReplyDeleteAbout MVC so much is left behind Please Add with this Page ++++++++++++++++++++++++++)
Great Article...
ReplyDeleteASP.Net MVC Training
Online MVC Training
Online MVC Training from India
MVC Training in Chennai
Dot Net Training in Chennai
.Net Online Training
ASP.NET Training
It's Really A Great Post. Looking For Some More Stuff
ReplyDeleteBest Dotnet Training in Bangalore
Best Oracle Training in Bangalore
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteVery useful,but very less in number.Expecting more questions....
ReplyDeleteC# Tutorials
Hiya,
ReplyDeleteI love all the posts, I really enjoyed.
I would like more information about this, because it is very nice., Thanks for sharing.
I was wondering what's a good library or some code to find the similarities between one image and another image/images. I have some software I'm writing where the user has a set of images and he/she wants to compare one image to the rest and then output the similarities into an image file
to visually see the differences. I've used code before to do very simple compares but they're not detailed enough and I have no clue how to output the similarities or differences into and image file. Does anyone have any ideas?
I am so grateful for your blog. Really looking forward to read more.
Kind Regards,
Irene Hynes
best office chair india
ReplyDeleteSome time all you have to do is arrange some Good quality office chairs from top brands to make your home office look really awesome and fantastic. Adding a good office vibe is really important trust me.
ReplyDeleteHere in this article we ;re sharing with you the step by step guide on how to install the printer that hp printer printing blank pages. The steps would be easy to follow.
ReplyDeleteReally infomational and educative article thanks publisher for sharing this wonderful info i have shared this article on my blog tecktak flippzilla
ReplyDeleteand whatsaup, and Best smart tv