asp.net-mvc-2

MVC Validation using Data Annotations - Model classes or View Model classes?

Is it best practice to put data validation annotations in the Model or View Model? What are the advantages/disadvantages of one approach over the other? Curious to see where everyone is putting their validation, I am currently doing it in the model project. However I have seen a few people say this is not best practice. ...

MVC Validation using Data Annotations - Scenarios where it doesn't work, Alternatives?

So I have been using data annotations for my validation in an MVC project and they seem to work in most scenarios. Here are two examples in my current project where they don't seem to fit and I am unsure of the best place to put the validation. 1) I have a Join League page that contains a form where the logged in user enters their t...

ASP.NET MVC output cache with dynamic fragment

How could I cache an entire page except a bit at the top which says something along the lines of "Welcome back, Matt! | Log Out" if the user is logged in and so-on? I'm using ASP.NET MVC 2. ...

Need some help understanding the usage of this Html.ActionLink().

I'm following the NerdDinner ASP.Net MVC tutorial and I have the following line of code: <%= Html.ActionLink("Edit Dinner", "Edit", new { id = Model.DinnerID}) %> | <%= Html.ActionLink("Delete Dinner", "Delete", new { id = Model.DinnerID }) %> What I don't understand is why the third parameter of the ActionLink requires a new ...

partial views in ASP.NET MVC?

Hi, I have a three database tables related for example: company( one - one) Contact( one- one) Address, I need to create a company, then create contact for company, then create an address for contact in one page (to make things easier for user). the user doenst have to fill all the details at once and submit it, he may create company ...

How to handle UnauthorizedRequest via Ajax call in Asp.net MVC2

Brief: I have a sub classed AuthorizeAttribute in my framework in which I am doing custom authorization. I am in the process of switching from normal asp.net mvc view rendering to Ajax rendering via jQuery. Hence every link in the application does a ajax call to get the data. In order to cater for this I have converted most of my page...

Is possible to add waypoints to Google Maps API without using JSON?

I'm on ASP.NET MVC and I'm using Google Maps API with Javascript. I send a Model to the View with one or more waypoints to add to the route. function calcRoute() { initialize(); var start = "<%= Model.StartAddress %>"; var end = "<%= Model.ClientAddress %>"; var waypts = []; waypts.push...

add telerik asp.net ajax controls to asp.net mvc views

Hi I am looking for any tutorial or document about how to use telerik asp.net ajax controls with asp.net mvc views thanks ...

How do I implement ASP.NET MVC 2 validation that checks the database?

All examples that I can find do something like this: [Required] public string Title { get; set; } That's great for simple cases, but what about something that checks the database or something else server side? For example, say I have a movie database and I want to allow people to rate it. How could I tell if someone has already rated...

asp.net mvc simple question

I'm creating asp.net mvc login page. This is simple. Same as others. Controller contains 2 method. My problem is I'm debugging First LogOn method. ReturnUrl has value. for example "Admin/Index". After debuggin Second LogOn method. But ReturnUrl is Null. public ActionResult LogOn(string ReturnUrl) // First method { return View()...

very long build - ASP.MVC 2 in VS2010

I'm developing Asp.MVc 2 application. In solution i've about 10 projects and i have no idea why bulid takes so much time - ~5 minutes. I've tried to unload some projects, but it saves mayby 15 seconds. I'd like to try and learn TDD, but writing and running tests will waste 80% time. I'm using VS2010 and default MSBuild - is there any ...

Javascript multiple file uploader error in Asp.Net MVC : cancel button doesn't work

i have error in CANCEL button in file uploader.The CANCEL button does't work if i tried to remove(cancel) ADD MORE FILE button. here is the javascript code: <script type="text/javascript"> function addFileUploadBox() { if (!document.getElementById || !document.createElement) return false; /*************...

Providing MVC Shared Folder Structure

I'm working on a project and I would like to be able to place a number of views within the shared folder. However when these are all created (through a generation process) i begin to feel "custer&^%$ fobic" due to having X * N partial views within the shared folder and am looking for a better organizational model. Is it possible to ju...

adding/removing a file in VS2010 causes "WebDev.WebServer20.exe has stopped working" error

This is driving us crazy... In VS2010, MVC2 projects, not all projects.... both on a project that was upgraded from 2008/mvc1 and on a brand new project created within 2010/MVC2, we have the following behavior: 1) develop as normal.. 2) hit F5 or CTRL-F5 to open up a browser 3) works great! 4) add a CSS file (or JS file or any file...

ASP.NET MVC 2 and Google Maps Javascript API Version 3

Somehow I cannot get a simple map to work in a ASP.NET MVC 2 application with Google Maps Javascript API V3. I have tried the following: Site.Master: Removed <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; Added <!DOCTYPE html> Added this in < head > <script type="...

JQuery: How to handle ASP.Net MVC 2 View objects in Ajax data?

I'm handling the submit portion of a ASP.NET MVC 2 page via javascript/JQuery because i need to construct some arrays, in the controller i either return back a View (if there are errors) or a URL (redirect) I can handle the URL fine, but i have no idea how to handle returning a View object public ActionResult Update(List<string> items,...

How can I get action name?

Hi folks, I replaced the ASP.NET ControllerFactory by a WindsorControllerFactory. And I registered all controllers and interceptors. Until here everything working well. Now when I am debuging my Interceptor I always get Execute from ControllerBase in invocation.Method.Name. I need to get the action name and the parameters of the acti...

Where can I find some MVC User Administration Helpers for AD Users?

So I have an MVC 2 app that uses the Active Directory Membership Provider. Authentication works like a charm! Now I need to add some additional screens to allow the users to: Change their password Reset forgotten passwords (email a super secret link or something?) Conditionally add additional users (of course users of a certain role, a...

ASP.NET MVC - How do I load an image asynchronously?

On the home page of my site I want to display a lot of products which have images which are quite large. Currently the page is taking so long to load that it is actually timing out and the page fails to display! In MVC, or just ASP.NET in general, how can I load an image asynchronously? Basically what I want to do is display the detail...

ASP.NET MVC 2.0 Custom Client Validation

I am trying to make a validator that will make sure that at least 2 items are selected. The validator works correctly on the server side but the client side code never gets executed. Here is the code: Sys.Mvc.ValidatorRegistry.validators["country"] = function (rule) { var min = rule.ValidationParameters["min"]; ...