How do I define a method in Razor?
How do I define a method in Razor? 8 Answers 8
How do I define a method in Razor? 8 Answers 8
I am writing my first Razor page today, and can’t figure out how to enter #if debug … #else … #endif How can I do that in Razor? 10 Answers 10
Razor encodes string by default. Is there any special syntax for rendering without encoding? 6 Answers 6
I’ve got a property in my model called Promotion that its type is a flag enum called UserPromotion. Members of my enum have display attributes set as follows: [Flags] public enum UserPromotion { None = 0x0, [Display(Name = “Send Job Offers By Mail”)] SendJobOffersByMail = 0x1, [Display(Name = “Send Job Offers By Sms”)] SendJobOffersBySms = … Read more
What is the final/best recommendation for how to serve favicon.ico in ASP.NET MVC? I am currently doing the following: Adding an entry to the very beginning of my RegisterRoutes method: routes.IgnoreRoute(“favicon.ico”); Placing favicon.ico in the root of my application (which is also going to be the root of my domain). I have two questions: Is … Read more
I have a textarea control that accepts input. I am trying to later render that text to a view by simply using: @Model.CommentText This is properly encoding any values. However, I want to replace the line break characters with <br /> and I can’t find a way to make sure that the new br tags … Read more
So, the title should speak for itself. To create re-usable components in ASP.NET MVC, we have 3 options (could be others i haven’t mentioned): Partial View: @Html.Partial(Model.Foo, “SomePartial”) Custom Editor Template: @Html.EditorFor(model => model.Foo) Custom Display Template: @Html.DisplayFor(model => model.Foo) In terms of the actual View/HTML, all three implementations are identical: @model WebApplications.Models.FooObject <!– Bunch … Read more
I would like to have 2 separate Layouts in my application. Let’s say one is for the Public section of the website and the other is for the Member side. For simplicity, let’s say all the logic for each of these sites is wrapped neatly into 2 distinct controllers. PublicController StaffController And that they each … Read more
Is there any difference between HTML.ActionLink vs Url.Action or they are just two ways of doing the same thing? When should I prefer one over the other? 6 Answers 6
I’ve been searching on SO & Google for a breakdown of the various View Engines available for ASP.NET MVC, but haven’t found much more than simple high-level descriptions of what a view engine is. I’m not necessarily looking for “best” or “fastest” but rather some real world comparisons of advantages / disadvantages of the major … Read more