asp.net-mvc-2

ASP.NET MVC Display Template for Generic Type

╄→гoц情女王★ 提交于 2019-12-04 13:08:52
I am trying to use the model ListModel as a generic list model. I would like to enter on the page @Html.DisplayForModel() However the MVC is not correctly finding the templated file "ListModel.cshtml". It must work differently for generic models. What should I name the templated file in order for it to correctly be located? public class ListModel<T> { public IEnumerable<T> Models { get; set; } public string NextPage { get; set; } } I would expect it to look for Shared/DisplayTemplates/ListModel.ascx but it doesn't. Does anyone know? Edit: I did end up solving this by simply removing the

Multi step wizard form with MVC

℡╲_俬逩灬. 提交于 2019-12-04 13:06:58
I'm planing to build a multi-step form with asp.net mvc 2. So, my web application will have 5 pages correspond to 5 steps. Each step has two submit buttons, previous and next. Input data for each step will be stored for reviewing later. For example, we already inputted data for step s 1,2,3,4 and we are in step 5 now. When I click on "previous" 2 times, step 3 should be displayed with data I inputted before. Similar, when I click "next", inputted data should also be retained in step 4 (since we are in step 3 now) Model used for each step can be very different. I'm seeking a solution to save

Post array in ASP.NET MVC 2 using name=“array_name[]” for form elements

你。 提交于 2019-12-04 12:53:02
问题 Good day! In PHP it is possible to assign name attribute to input elements with square brackets, like this: name="my_value[]" and PHP automagically converts this to array on server side. Is this possible in ASP.NET MVC? If not is there any alternative to process a bunch of checkboxes in ASP.NET MVC? Thanks in advance! 回答1: Yes, it is possible. You might take a look at the following blog post about the convention used by the default model binder. 回答2: Make sure the name is still the same, but

Dynamic validation on MVC 2

好久不见. 提交于 2019-12-04 11:59:28
This works fine [MetadataType(typeof(Area_Validation))] public partial class Area { ... } public class Area_Validation { [Required(ErrorMessage = "Please add this field.")] public int Email { get; set; } [Required(ErrorMessage = "Please add this field")] public string Name { get; set; } } but how about if Area_Validation is dynamically created ? for example Subscription Fields that on back-end can be created by the user and end up like this: How can I set the Metadata on each field for auto validation ? Currently I'm doing: public class SubscriberFormViewModel { public List

Sample MS application for ASP.NET MVC?

南笙酒味 提交于 2019-12-04 11:16:52
问题 I am getting started with my first MVC project and want to start off on the right foot. I know the basics of how to create a quick and dirty MVC application. However, I'd like to get my hands on a resource that uses best practices for developing ASP.NET MVC applications (either a document or a sample quickstart app) Any help is appreciated 回答1: NerdDinner is the seminal ASP.NET MVC example. Once you've grokked that, move on to Orchard CMS for an amazing example of a totally loosely-coupled,

Using a CSS File for site localization

你说的曾经没有我的故事 提交于 2019-12-04 11:06:42
问题 I'm creating a website with ASP.net MVC 2.0 which uses two different languages (English and Persian). I want to have two different layouts for these languages, English has a left to right and Persian has a right to left layout. What came to my mind was, if I could have two different css files, like when you do it with string or image localization will do the work for the site, the problem is I need to know how to do this! Any other suggestions on how to perform this would be helpful. 回答1: You

ASP.NET MVC & Repository Pattern Understanding

廉价感情. 提交于 2019-12-04 11:01:11
So I'm extremely new to ASP.NET MVC and Interface design. I've been asking a lot of questions and reading a lot of articles trying to make sense of it all. Due to a crisis at work, I have been called upon to do my best and learn this environment. And although it's been frustrating to grasp, I am slowly getting it. I have created an image in photoshop that shows my basic understanding of how the Repository Pattern works and why it's very much recommended. I'm trying to deploy this pattern at work and I want to make sure I get the major points I ask you to point out any glaring (not anal or

How to reinstall MVC 2 tools for VS2010?

℡╲_俬逩灬. 提交于 2019-12-04 10:29:39
问题 I accidentally uninstalled the Asp.Net MVC 2 Tools for Visual Studio 2010. How can I reinstall it? The MVC2 download only seems to include the VS2008 tools. Everything I've googled says that MVC 2 is included in VS2010, but a repair install didn't fix it, and MVC 2 isn't listed as a selectable component in the VS2010's add/remove components screen. 回答1: You'll find VS2010ToolsMVC2.msi on your VS2010 DVD under WCU\ASPNETMVC - hopefully that will do it! 来源: https://stackoverflow.com/questions

How to redirect a POST request to a url maintaining model values in MVC

余生颓废 提交于 2019-12-04 10:27:28
I have a fairly standard sort/filter/page search form but need control over the format of the url. The sort/filter/page parameters should all be part of the url so that, for example, the address could be emailed to someone. When another filter parameter is added, a POST request is made. My controller method looks like this: [HttpPost] public ActionResult Search(string filterField, Operator filterOperator, string filterValue, PeopleGroupSearchModel model); The PeopleGroupSearchModel is populated from query string parameters. The filter* parameters are coming from the posted form values. I would

Can I disable DataAnnotations validation on DefaultModelBinder?

落花浮王杯 提交于 2019-12-04 09:42:21
I want DefaultModelBinder not to perform any validation based on DataAnnotations metadata. I'm already using DataAnnotations with DynamicData for the admin area of my site, and I need a different set of validation rules for the MVC based front-end. I'm decorating my classes with the MetadataType attribute. If I could have different MetadataType classes for the same model but used on different scenarios that would be great. If not I'm fine with just disabling the validation on the DefaultModelBinder, either by setting some property or by creating a specialized version of it. Take a look at