asp.net-mvc-2

Should I have different models and views for no user data than for some user data?

I'm just starting to learn asp.net mvc and I'm not sure what the right thing to do is. I have a user and a user has a collection of (0 or more) reminders. I have a controller for the user which gets the reminders for the currently logged in user from a reminder service. It populates a model which holds some information about the user ...

How to install ASP.NET MVC 2 templates after already installing VS Web Dev 2010 first?

First off these questions are related but do not fix my problem: http://stackoverflow.com/questions/2499934/ http://stackoverflow.com/questions/652836/ I have installed Visual Studio Web Developer Express Edition 2010, then I installed MVC 2. Now I can successfully run a MVC 2 application, however I have to do the manual impo...

ASP.NET MVC Page - hyper links in HTML.ValidationSummary

Hi I have Registration page and if the validation fails, it displays the error messages using HTML.ValidationSummary control. Now i have to display the Hyperlink in that Validation Error Message. But it is treating href also as string. The Validation Message that I am trying to display with hyperlink is: **"User already exists in the ...

In ASP.NET MVC, how do I display a property name as a label splitting on CamelCase

I know that I have seen this before. I can't remember if it was a C4MVC template demo or an input builder thing! I need to know how I can use the convention of CamelCasing my view model properties and having the "CamelCasedProperty" rendered in the label as "Camel Cased Property". This should be handled by the create new view wizard r...

Best practice for submits redirecting to another page in MVC2?

I have a situation with my MVC2 app where I have multiple pages that need to submit different information, but all need to end up at the same page. In my old Web Forms app, I'd have just accomplished this in my btnSave_Click delegate with a Redirect. There are three different types of products, each of which need to be saved to the car...

Determine if a url matches a Route, and pull out the terms if it does

I've got a big old log file I'm trying to break down in terms of routes. Essentially, I'm getting input of a path (/questions/31415 for example) and a list of all the registered Routes. What I want out is a Route and the parameters specified in the route (so in, /questions/{id}/{answer} I'd get id and answers out). I've got a working ...

multiple validation errors showing up for single property

i'm often getting multiple errors showing up for an individual property, when I'd like them to be prioritized, as in, if Required is satisfied, check StringLength, but if Required fails, show that message only. I'm getting inconsistent behavior here, and I'm curious as to how the framework determines this priority? has anyone else ha...

Where to store 3rd party libraries?

I have asp.net mvc 2 application. Now I'm reimplementing it for working with Ninject. All is fine except one thing: where should I store Ninject.dll?? I've created lib directory inside my appdir and made reference to lib/Ninject.dll. But may be there are some general conventions on how to act in such cases? ...

How to update model in the database, from asp.net MVC2, using Entity Framework?

Hello. I'm building ASP.NET MVC2 application, and using Entity Framework as ORM. I am having troubles updating object in the database. Every time I try entity.SaveChanges(), EF inserts new line in the table, regardless of do I want update, or insert to be done. I tried attaching (like in this next example) object to entity, but then I g...

ASP.NET MVC 2 Display Name DataAnnotaion from Resource not working

Hi, I'm trying to use a resource file to hold label text for the Model in an MVC 2 project. I've got the following class... public class Person { [Display(ResourceType = typeof(Resources.Labels),Name="First")] public string FirstName { get; set; } public string LastName { get; set; } } ...and have tried using... <...

How do I populate the Watermark property on ModelMetaData?

I've just finished reading http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-2-modelmetadata.html In the article Brad lists the Watermark property but there is no mention of which DataAnnotation is used to populate it. ...

ASP.NET MVC - Get Current Area Name in View or Controller

How do you get the current area name in the view or controller? Is there anything like ViewContext.RouteData.Values["controller"] for areas? ...

when using Automapper, Should I flatten/map my internal objetcs of the View Model also ?

Hi all, I am using AutoMapper in my project along with, NHibernate and ASP.NET MVC 2. As the title states, if I have a list of DTOs or a DTO inside the parent DTO that I am mapping to the View Model, should I flatten out the inner DTOs as well ? Edit: Should I write view model classes for the internal objects as well or should I use ...

ASP.NET MVC & ADO.NET Entity Framework clientside validation

Using aspnet mvc2 with the model auto-generated by entity framework: Is it possible to tell entity framework to auto-annotate all fields? eg: If database field says not null then add [Required] If DB field is a nvarchar(x) then add [StringLength(x)] And so on? What if the field name contains the string "email" eg CustomerEmail - can...

mvc renderpartial dialog difficulty

Hi, I have a view in which I have the following code: <div id="DivPassword" > <%Html.RenderPartial("PasswordDetails"); %> I want to display the div as a dialog, in which I am successful. When I click on a link the dialog opens. However, I can see that the partial view is also being displayed in the View, when the page loads. ...

mvc views not found when using mvc combined with webforms CMS in asp.net

We have a website build in the umbraco 4.1 cms (webforms) default .net 3.5 And we have some MVC tools and controls build with MVC2.0 on .net 4.0 i've managed to let the umbraco cms run in .net 4.0 and i've been following parts of this guide (for mvc 1.0 and umbraco 4.0.3) but now i'm stuck, umbraco has alot of url management itself, s...

Handling ID's with db4o and ASP.NET MVC2

So, i'm looking at the TekPub sample for ASP.NET MVC2 (http://mvcstarter.codeplex.com/) using DB4o and there are a bunch of templates to create controllers etc, the generated code looks like: public ActionResult Details(int id) { var item = _session.Single<Account>(x=>x.ID == id); return View(item); } Now, ...

What is the difference (if any) between Html.Partial(view, model) and Html.RenderPartial(view,model) in MVC2 ?

Other than the type it returns and the fact that you call it differently of course <% Html.RenderPartial(...); %> <%= Html.Partial(...) %> If they are different, why would you call one rather than the other one? The definitions: // Type: System.Web.Mvc.Html.RenderPartialExtensions // Assembly: System.Web.Mvc, Version=2.0.0.0, Cultu...

How to handle global Exception in ASP.Net MVC 2

My base controller has this override: protected override void OnException(ExceptionContext filterContext) { // http://forums.asp.net/t/1318736.aspx if (filterContext == null) { throw new ArgumentNullException("filterContext"); } // If custom errors are disabled, we need to let the normal ASP.NET exception han...

MVC2 Model Binding Enumerables?

Okay, so I'm fairly new to model binding in MVC, really, and my question is this: If I have a model with an IEnumerable property, how do I use the HtmlHelper with that so I can submit to an Action that takes that model type. Model Example: public class FooModel { public IEnumerable<SubFoo> SubFoos { get; set; } } public class Sub...