asp.net-mvc-2

MapRoute with generic controller

Is it possible to map a route with MapRoute and specify a generic controller e.g context.MapRoute( "Dashboard_Edit", // Route name "dashboard/edit/{*pagePath}", new { controller = "Dashboard`1", action = "edit", pagePath = "home" } ); ...

ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder

Given an action like: public ActionResult DoStuff([CustomAttribute("foo")]string value) { // ... } Is there any way to resolve the instance of value's CustomAttribute within a ModelBinder? I was looking at the MVC sources and chances are I'm just doing it wrong, but when I tried to replicate their code which retrieves the BindAttrib...

Is it possible to use data annotations for LabelFor,ValidationMessageFor, EditorFor with strongly typed resources?

I would like to use DataAnnotations in my ASP.NET MVC application. I have strongly typed resources class and would like to define in my view models: [DisplayName(CTRes.UserName)] string Username; CTRes is my resource, automatically generated class. Above definition is not allowed. Are there any other solutions? ...

Html.TextAreaFor not writing the value...? (ASP.NET MVC 2.0)

basically, im calling Html.TextAreaFor to display a form, which is great/not a problem... people enter text in it, and it gets submitted, and if it is successful, i want to return an empty Html.TextAreaFor... but after it's submitted, in the action method i am clear to set the Comment that people are making in the TextArea to an empty s...

asp.net MVC UIHint naming a input or textarea automatically

hi there I am using editor and display templates on my MVC project with MetaData I use something Called UIHint that enables me to show a particular control for example all my description fields require a textarea that is using tinyMCE however i want the name of the textarea to match the name of my field: i.e i have Model Employee, wi...

asp.net MVC passing generic model to EditorTemplate UIHint

hiya when using EditorFor(model => model.FieldName) i want to have a generic say datepicker, rich text editor, upload box etc but with editorFor you cant pass a value, so you have to create a strongley typed element for each model that requires one of the above. anyone know if you can pass a generic model or a generic value like usin...

hmmm CKEditor shows editor but the textbox is still on my page too in asp.net MVC

i have this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %> <script src="<%=Url.Content("~/Scripts/ckeditor/ckeditor.js")%>" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { var CurrName = $(".ckeditor").attr("name"); CKEDITOR.replace(CurrN...

ASP.NET MVC 2 Action Method receives null arguments

I'm having a problem with an ASP.NET MVC application that I'm developing. I'm still fairly new at web development and in particular MVC, so please forgive me is this is a really stupid newbie mistake ;-) I have a view that displays a list of products. Each product has a 'details' link that I want to link to a details view for that produ...

CSRF Protection in AJAX Requests using MVC2

The page I'm building depends heavily on AJAX. Basically, there is just one "page" and every data transfer is handled via AJAX. Since overoptimistic caching on the browser side leads to strange problems (data not reloaded), I have to perform all requests (also reads) using POST - that forces a reload. Now I want to prevent the page agai...

Asp.net MVC: Edit html control for Admin

I have a Asp.net MVC web application, containing mostly text. I want to put a feature into it so that admin can easily edit text/html using the web. May be some double clicking on a page and converting it into editable and save able. How can i do it? any sample code? I need this to be done for Asp.net MVC. ...

Asp.net MVC Edit in Place

There are already jQuery based Edit in place plug ins available. But i am not sure how can i use them with Asp.net MVC. Any code sample for controller? I want to edit the .aspx files as my web application is not getting text/content from database... ...

Asp.net MVC: Map path to view???

I am posting a form to url /Admin/EditInPlace from page /About In EditInPlace's conroller code i can find the Url-Referrer i.e. from which page request is coming. But how can i map the Url-Referrer to its View page?? In short how can i found that a page /xyz is mapping to which View.aspx file programmatically? ...

Is it possible to send object as route value in RedirectToRouteResult?

First of all, it needs to create some codes that handle any error in my application like the following code. public class HandleSomeErrorAttribute : HandleErrorAttribute { public string ControllerName { get; set; } public string ActionName { get; set; } public override void OnException(ExceptionContext filterContext) { ...

MVC to MVC2 Errors

I've just updated to VS2010 (rc) and subsequently been forced to update my projects and convert to MVC2 (ta microsoft)... which has scuppered the first app its touched. Error 2 'System.Web.Mvc.IValueProvider' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Web.Mvc...

DisplayFor ignores metadata

For my Contact class, the property EmailAddress is marked with the [DataType(DataType.EmailAddress)] attribute. In my view, using Html.Display("EmailAddress") and Html.DisplayFor(c => c.EmailAddress) yields different results. The former outputs a mailto: link, which is the expected behavior, while the latter simply outputs the email add...

JMOL pdb files not being served

I am building an asp.net mvc web site which needs to host some JMOL content. JMOL is an open-source Java viewer for chemical structures in 3D. http://jmol.sourceforge.net/ The problem is that when I host the JMOL files which have been created for this site on IIS, I get errors when JMOL attempts to load the .pdb files. e.g. java.io.I...

Is there a way to update a ViewModel in MVC2?

This code works: [HttpPost] public ActionResult Edit(int id, FormCollection fc) { Movie movie = ( from m in _ctx.Movie.Include("MovieActors") where m.MovieID == id select m ).First(); MovieActorViewModel movieActor = new MovieActorViewModel(movie); if (TryUpdateModel(movieActor)) ...

Going from VS 2010 Beta 2 to VS 2010 RC in MVC 2 projects causes 'The project type is not supported by this installation.'

I just installed VS 2010 RC and now my MVC 2 project created in VS 2010 Beta 2 won't load stating: 'The project type is not supported by this installation.' Sweet! What the hell do I do now? Anyone else having this issue? ...

How to use a DotNetNuke Membership database within an ASP.Net MVC Application

I'd like to supplement my existing DotNetNuke website with a side application which is built on MVC. To do this, I'd like to set the MVC application up on a separate subdomain (e.g. subapp.mydomain.com) and to connect to the same database. I've tried this already and I can get the MVC app to connect at the ASP membership levels (just u...

Unit testing an ActionFilter - correctly setting up the ActionExecutingContext

In a custom ActionFilter, I want check the attributes on the controller action that will be executed. Running through a small test application, the following works when launching the app in the asp.net development server- public class CustomActionFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting(Action...