asp.net-mvc-2

Asp.net MVC 2, MvcContrib, and a base controller with redirect actions

I've got a base controller that takes a couple generics, nothing overly fancy. public class SystemBaseController<TForm, TFormViewModel> : Controller where TForm : class, IForm where TFormViewModel : class, IViewModel ok, no big deal. I have a method "CompleteForm" that takes in the viewModel, looks kinda like this ... pu...

ASP.NET MVC 2 client-side validation rules not being created

MVC isn't generating the client-side validation rules for my viewmodel. The HTML just contains this: <script type="text/javascript"> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({"Fields":[],"FormId":"form0","ReplaceValidationSummary":false}); ...

Validation Summary for Collections

Hi All, EDIT: upgraded this question to MVC 2.0 With asp.net MVC 2.0 is there an existing method of creating Validation Summary that makes sense for models containing collections? If not I can create my own validation summary Example Model: public class GroupDetailsViewModel { public string GroupName { get; set; } public int Nu...

Getting the error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"

I've just installed MVC2 and I've got a view that looks like this <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Home.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Home </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID...

Action not found in Route table?

Hi, Just started my first MVC 2.0 .net application. And I set up some default pages like: /Loa/Register /Loa/About But when I request for /Loa/sdfqsdf (random string) I get the "The resource cannot be found." error, how can I redirect this non-existing action to a default action? Like an "action not found" default action? thx! ...

ASP.NET MVC 2 - ViewModel Prefix

I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted. Main View: <div> ...

Using a custom MvcHttpHandler v2.0 Breaking change from 1.0 to 2.0 ?

Hi I have a site where part is webforms (Umbraco CMS) and part is MVC This is the HttpHandler to deal with the MVC functionality: public class Mvc : MvcHttpHandler { protected override void ProcessRequest(HttpContext httpContext) { httpContext.Trace.Write("Mvc.ashx", "Begin ProcessRequest"); string originalPat...

Ninject 2 and MVC 2.0

I've updated a project to VS2010 and MVC2 from VS2008 and MVC1. I'm having problems with Ninject not finding controllers within Areas Here is my global.asax.cs file: namespace Website { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class MvcApplication : Ninje...

a potentially dangerous request.form value was detected but validateinput(false) not working

I have installed VS2010 and MVC2 and testing a simple form using tinyMCE. When I post the contents of the textarea in tinyMCE I get the dreaded YSD and the message "a potentially dangerous....." No problem I thought - seen this before so I put the ValidateInput(false) on the controller but no joy - I still get the error. page code in ed...

Model validation with enumerable properties in Asp.net MVC2 RTM

I'm using DataAnnotations attributes to validate my model objects. My model class looks similar to this: public class MyModel { [Required] public string Title { get; set; } [Required(ErrorMessage = "At least one editor is required.")] public List<User> Editors { get; set; } } public class User { public int Id { get...

MVC2: Best Way to Intercept ViewRequest and Alter ActionResult

I'm building an ASP.NET MVC2 Web Application that requires some sophisticated authentication and business logic that cannot be achieved using the out of the box forms authentication. I'm new to MVC so bear with me... My plan was to mark all restricted View methods with one or more custom attributes (that contain additional data). The ...

Problems deploying MVC2 - Could not load type 'System.Web.Mvc.UrlParameter'

I have problems deploying MVC2 application to my hosting. It shows the following error: Could not load type 'System.Web.Mvc.UrlParameter' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. It looks like it does not understand the new "optional URL parameters" feature of MVC2. This is just...

ASP.NET MVC The new ActionLink with MvcHtmlString and request URL generated

This piece of code used to work in MVC 1 but it does not since I upgraded to MVC 2: <%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create" + "?modal=true", "Widget", null, new { rel = "shadowbox;hei...

Why input elements don't render the value passed in ASP.Net MVC?

This post asks this question but doesn't really give an answer, so I thought I would ask the question differently. I have a page that renders a hidden value from the model: <%=Html.Hidden("myName", model.myValue) %> Since I am passing a value in the value parameter, you would think it would output that value, but it doesn't. The cod...

Using "Go To Controller" and "Go To View" in Visual Studio 2008 when controllers are in different assemblies asp.net mvc 2

The title is basically the question. We decided to move our controller classes to a separate library and reference it in our asp.net mvc 2 application. It works just fine when running the application, meaning the controllers are being referenced while the application is running. But when doing development (in Visual Studio 2008) and I...

How to manipulate data in View using Asp.Net Mvc RC 2?

I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId], [BirthDate], [Gender], [Active] Gender and Active are Bit that hold either 0 or 1. I am displaying this data in a table on my View. For the Gender I want to display 'Male' or 'Female', how and where do I manipulate the 1's and 0's? Is ...

Globalization for ASP.NET MVC 2 Validators

Is there anyway to override the custom validation error messages from the ValidationAttributes? Basically I need the ValidationAttributes to support globalization. ...

Are there any ASP.NET MVC Real Time View Editors?

I'm looking for a tool and I'm not even sure of the proper name. Please be patient with me as I explain. I'm doing a lot of HTML/MVC 2 work. Using the standard MVC 2 view engine, I would like to have an editor that shows real time changes in the browser. If I re-arrange div elements containing standard HTML and some server side compo...

what is the best way to use Html.DropDownListFor when you have a list of objects ?

In my view model if have a: List<Car> where car has an Id and a name. I want to create a dropdown box using Html.DropDownListFor() what is the best way to hook this up as i want to have the value of the item be the Id and the display to be the Name of the Car. ...

ASP.NEt MVC 2 Client validation function in Ajax form

Hello, My problem is the following: I'm using client validation function of the MVC 2.0 framework. Everything is nice, when I use the validation in a simple form. But when I use an Ajax form, and I update the fields of the ajax form, the client validation doesn't work. I think about, I have to refresh the validation after the ajax c...