asp.net-mvc-2

Dynamically add items to a collection in MVC2 using EditorFor()

I'm trying to do this: Editing a variable length list, ASP.NET MVC 2-style In the post he mentions that it could be done with less code using Html.EditorFor(), but that it would be more difficult because of the indexes. Well, that's exactly what I want to do, and I don't know where to begin. I'm an ASP.NET novice who just completed th...

how to unit test the CustomWebFormViewEngine.FindView(...) method with Mock controllerContext?

Want to unit test the following piece of code. can some one help me out? I saw many post that we can use different open source frameworks like Rhino mocks, moq etc. But I can't figure it out what exactly required to mock how the value should intilize while creating mock objects. my class is as follows. public class CustomWebFormViewEngi...

Why to use Foolproof validation in ASP.NET MVC 2 and DataAnnotations 4?

I understand that Foolproof validation extends DA and adds support for validation attributes as listed here However, most of the validations that are listed can be in theory be accomplished by writing custom validators. Why would I need to use this library? Thanks ...

How do you implement a culture-specific address form using ASP.NET MVC?

We currently have a WebForms control with an update panel. The code-behind contains logic to show/hide fields based on the selected country. This is fine for WebForms, but we ware moving to MVC, and I'm having a hard time sorting this out. I also need this to be localized, both in terms of localizable resource strings as well as displayi...

I need a better recommendation for handling custom User Properties with OpenID Membership

I'm using DotNetOpenAuth as my membership system, and the way I have it working now seems to be working quite well. What I'd like to do however is build into my website the ability to check user credentials against the AuthCookie rather than a session. In the membership provider, I can check for the username like this string UserN...

Is there a class defined for the Action + Controller pair?

I would like to create a mapping table between the value of an enum and an action / controller (i.e. Dictionnary). Is there something already defined in MVC 2 that I could reuse or I have to create my own classes? Here is what I would like to do: <%= Html.ActionLink(this.Model.Mapping[MyEnum.Value].Action, this.Model.Mapping[MyEnum.Val...

Partial View on a different project

How can I make a partial view on a separate dll, and add it to a MVC project? There is any why to create the same ascx in a dll, and to work for a MVC project and a Webform project? Thanks! ...

Render View programmatically into a string

I would like to get the html code a view would generate in a string, modify it in my controller, then add it to my JsonResult. I found code that would do what i'm talking about from a partial. I would like to do it from an aspx View though. -- Extra explanation: Let's say I have a page Frame.aspx that /Controller/Frame will return I ...

asp.net mvc 2 website MUCH slower on IIS 7.5 vs built-in server

I am taking some time to learn how to develop asp.net mvc2 websites, but I'm used to working directly off IIS instead of the built-in web server that uses the random ports when you hit F5. but I've noticed that using the built-in webserver, requests fly and are immediate. I am using only the default project with the Home and About pages...

ASP.NET MVC 2 validation: Easy way to add CSS class to element on error?

I'm using ASP.NET MVC 2 and using Microsoft's beautiful new 'DataAnnotations' to provide some validation hints for my model. I can get the validation messages to display... but here's the rub: I'd like to add a CSS class to a specific div when there is a validation error involving a specific field. I figure I can brute force this by...

ASP.NET MVC2 - Dynamic list of checkboxes and model binding

I'm trying to create a view that contains a list of checkboxes that is dynamically created from a database, and then retrieve the list of selected ones when the form is posted back. My EF model contains a class: public class ItemIWouldLikeACheckboxFor { public int Id { get; set; } public string Description { get; set; } } I...

Return from redirect

How can i redirect user in filter to another action and remember action which he wanted to do before redirect and repeat it after he do any action on that redirected page? ...

How to efficiently update models with references(dropdownList )with asp mvc and nhibernate

Hello, I started to develop a web application (application portfolio) with nhibernate and asp mvc2. I have some difficulties to properly change the category of an application. Here are my models: public class Application { public virtual int Application_ID{ get; private set; } public virtual string Name { get; set; } pu...

MVC 2 routing question

I'm trying to create a route that looks like this site.com/controller/{Param1}/{dbID}-{friendly-name} and omit the default action index , and for the action edit to be at the end of the url like so site.com/controller/{Param1}/{dbID}-{friendly-name}/edit routes are a bit confusing for me , so any help is appreciated , Than...

MVC 2: How to use Html.DropDownListFor?

I'm not exactly sure on my lambda's yet but why isn't the following working? 4/mvc2 Works: // SpotlightsController.cs public class SpotlightFormViewModel { // props public Spotlight Spotlight { get; private set; } public SelectList Featured { get; private set; } public IDictionary<string, int> feature = new Dictionary<...

switch from asp.net mvc 1.0 -> 2.0 - s#arp framework

Hi, I have an older asp.net mvc solution (s#arp framework) whith two projects one for web and one for controller. I have changed the dll to the latest versions (2.0) for System.Web.MVC and Microsoft.Web.MVC. I have also adjusted my Web.Config: <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364...

How to insert data to SQL Server DB using EF in MVC 2?

Hello All, How do insert data to a SQl Server 2008 database server using Entity Framework from a user input on a web application. I added a new EF connection o my model. I am able to see all the mappings correctly. I currently have the following in my view: <% using (Html.BeginForm()) { %> <%: Html.Label("Enter P...

MVC Validation Not Working In Web Forms Project

Hi, I have the following code in my aspx view page: <% using (Html.BeginForm()) { %> <div> CustomerCode:&nbsp; <%= Html.TextBoxFor(x=> x.CustomerCode) %> <%= Html.ValidationMessageFor(x => x.CustomerCode)%> and this code in my model: public class MyModel { [Required(ErrorMessage="customer code req")] [Stri...

Is there a way to a silverlight application trigger a javascript in an ASP page?

I have a Silverlight application with some maps, and in the same page this application is running, I have a table that describe the values related to the map. I want to create a way that when I put the mouse over some icon in the map, the row with the correspondent ID get highlighted. Is that even possible? I'm using simple asp tables, o...

Passing additional viewmodel data with EditorFor fails in one-to-many relatoinships

I have an editor template (Views/Shared/EditorTemplates/HORDER.ascx) which inherits System.Web.Mvc.ViewUserControl<CCOK2.Models.HORDER> My viewmodel has a one-to-many relationship which I use Html.EditorFor in order to render multiple HORDERS <%: Html.EditorFor(model => model.PEOPLE.HORDERS, new {fred="hello"})%> Eventually w...