model-view-controller

MVC Data annotation in different languages?

人走茶凉 提交于 2020-01-13 03:22:07
问题 I'm using code like this: @Html.LabelFor(m => m.Login.Password, new { @class = "adm" }) @Html.PasswordFor(m => m.Login.Password, new { @class = "adm", size = 30 }) @Html.ValidationMessageFor(m => m.Login.Password) It works fine as my data annotations/messages/labels are all in English. However is there some way I can have more than one language and switch between them? What if my site has a language selector that selects between Japanese and English? Can I have different data annotation for

How to create dynamic, multiple partial views using repository pattern in MVC

这一生的挚爱 提交于 2020-01-13 02:09:32
问题 I am trying to have a general home page that depending on the parameter passed to the control, different content (modules) will be displayed. For example, a user may select Kentucky from the menu and the id for Kentucky is 1. The home controller gets the id (1) and determines the possible modules for that state (a simple db call.) Perhaps there is an announcements module and a contacts module for the state. An announcements module could have several items but it's only one module. There would

MVC Dynamic Routes

妖精的绣舞 提交于 2020-01-12 10:19:07
问题 I would like to create dynamic urls that route to controller actions with an Id value. I've created the following route using a catch-all parameter routes.MapRoute( "RouteName", "{id}/{*Url}", new { controller = "Controller", action = "Action", id = "" } ); This works as expected and allows me to use the following Urls: "http://website.com/1/fake/url/path" (1 being the id that gets passed to the action method) Does anyone know a way to achieve it this way instead without creating my own http

MVC Dynamic Routes

半世苍凉 提交于 2020-01-12 10:19:04
问题 I would like to create dynamic urls that route to controller actions with an Id value. I've created the following route using a catch-all parameter routes.MapRoute( "RouteName", "{id}/{*Url}", new { controller = "Controller", action = "Action", id = "" } ); This works as expected and allows me to use the following Urls: "http://website.com/1/fake/url/path" (1 being the id that gets passed to the action method) Does anyone know a way to achieve it this way instead without creating my own http

Why should I use MVC in a php website? [closed]

人盡茶涼 提交于 2020-01-12 09:52:58
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Many frameworks are based on mvc, but I have no idea about MVC. So what is the use of MVC? Is it for speed, security or any other reason? 回答1: MVC allows you to separate your business logic from your presentation layer. This "Separation of Concerns" allows you to quickly find

Marionette.js CollectionView, only render specific models

China☆狼群 提交于 2020-01-12 07:53:06
问题 I am refactoring my Backbone.js application to use Marionette.js, and I am trying to wrap my head around a CollectionView . Suppose I have several ItemView s with the model Cow : // Declare my models. var Cow = Backbone.Model.extend({}); var Cows = Backbone.Collection.extend({ model: Cow }); // Make my views var GrassPatch = Marionette.ItemView.extend({ tagName: 'div', template: "<section class='grass'>{{name}}</section>", }) var Pasture = Marionette.CollectionView.extend({}); // Instantiate

MVC Mayhem; Sorting out Model responsibility and structure

孤街醉人 提交于 2020-01-12 07:14:26
问题 My understanding of MVC-type architectures over the last few weeks/months has advanced (I'd say) considerably, and I owe most of my thanks to fellow SO enthusiasts; so, thank you! I'm still challenged by something though, the Model . So far I've sorted out and created; A simple Request object, that consolidates request data (GET/POST/etc. params, HTTP headers, etc.) A simple Response object, that collects response data (HTML, JSON, HTTP headers, etc.) A fancy Router that resolves URIs against

RazorGenerator can't see custom cshtml helper

跟風遠走 提交于 2020-01-12 06:37:08
问题 I'm having a problem with RazorGenerator: it can't compile views that uses my custom helper: App_Code/ViewHelper.cshtml @helper test(System.Web.Mvc.HtmlHelper html) { <h4>Test</h4> } Views/Test.cshtml (...) @ViewHelper.test(this.Html) (...) When I try to compile my project I get this error for Test.cshtml: The name 'ViewHelpers' does not exist in the current context I tried adding various namespaces to my Views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc

RazorGenerator can't see custom cshtml helper

爱⌒轻易说出口 提交于 2020-01-12 06:37:07
问题 I'm having a problem with RazorGenerator: it can't compile views that uses my custom helper: App_Code/ViewHelper.cshtml @helper test(System.Web.Mvc.HtmlHelper html) { <h4>Test</h4> } Views/Test.cshtml (...) @ViewHelper.test(this.Html) (...) When I try to compile my project I get this error for Test.cshtml: The name 'ViewHelpers' does not exist in the current context I tried adding various namespaces to my Views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc

Reasons not to use MVC architecture for web application

喜你入骨 提交于 2020-01-12 04:21:11
问题 In the past I have primarily built all my web applications using an N-tier architecture, implementing the BLL and DAL layers. Recently, I have started doing some RoR development as well as looking into ASP.NET MVC. I understand the differences between the different architectures(as referenced by some other SO posts), but I can't really think of any reasons why I wouldn't choose an MVC model going forward for a new project. Is there any reasons/times in your experience when an MVC architecture