asp.net-mvc-2

Asp.net MVC retrieving a model object from a ViewModel

So I am using ViewModels to pass data from/to the web forms in my MVC application, as seems to be recommended practice from what I have read. My question is what is the normal approach to then map the ViewModel into an actual domain entity? I'm guessing I should probably add a 'GetObject' method to my ViewModels so I have something lik...

What control for date picking is good for MVC2?

What control can I use to select dates for ASP.Net MVC2? ...

Where do I put this javascript code?

I'm using jQuery UI for the first time, and I'm going to create a datetimepicker control for a DOB field. Here is how the view looks: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<StronglyTypedHelpers.Models.Person>" %> <asp:Content ID="Content1" ContentPlaceHolderID=...

Create/remove sitemap node in ActionResult - ASP.NET MVC SiteMap provider

I am using the ASP.NET MVC SiteMap provider to create dynamic sitemap nodes. It works when the application is first loaded, but I wish to add/remove nodes when an ActionResult executes (to add/remove a record from the database). My web.sitemap is as follows (taken out the parent node and other siblings) <mvcSiteMapNode dynamicNodeProvid...

redirect all requests to www.example.com to example.com in config without access to IIS

I'm currently planning to deploy a site with a third party hosting provider. I will only have access to the server via ftp and a tool similar to cpanel called WebsitePanel. No access to IIS set up or configs. Is there anyway to redirect http://www.example.com to http://example.com? ...

Syntax Error using dynamic linq with MVC 2.0's Ajax.BeginForm

Hey Guys, I got some problem with dynamic linq (link) and Ajax.BeginForm. Serverside I got the following Controller Action: [HttpPost] public ActionResult Ajax(String filter) { var count = (from e in context.Elements where(filter) select e).Count(); return Json(new { ElementCount = count }); } ...

ASP.NET MVC: Image upload validation

I'm trying to subclass ValidationAttribute in ASP.NET MVC 2 to make something along the lines of an ImageValidator class which would make sure that an uploaded image (from <input type="file">) has the correct mimetype, doesn't exceed the maximum allowed file size, etc. So where do I start? I get the feeling like images are an exception ...

How to do Integer model validation in asp.net mvc 2

I have a registration form and the user must enter the square footage of their house. I would like this value to be only an integer. Is there a way to validate this value using attributes asp.net mvc? ...

asp mvc 2 EditorFor strange behavior

ok i've defined a shared editor for string like the following <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <%= Html.LabelFor(model => model) %> <%= Html.TextBoxFor(model => model) %> <%= Html.ValidationMessageFor(model => model) %> now i'm calling the custom editor like ...

How should I handle an exception with ASP.NET MVC partial views?

I have a partial view (ascx) for displaying the top x articles of a person's RSS feed: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Models.Article>>" %> <% foreach (var item in Model) { %> <a href="<%: item.Url %>"><%: item.Title %></a><br /> <%: String.Format("{0:g}", item.Date) %...

ASP.NET MVC strongly typed view compilation error

This is a strange one. I changed something (not sure what) and now my app's view doesn't compile at runtime. The view itself is strongly typed: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyNamespace.OperatorModel>" %> When I visit the page, it fails to compi...

How to get values of Dropdownlist MVC 2 for insert in DB

Hi everyone, I am beginning in this issue MVC 2 I hope you can help me. I created a basic model public class RegisterModel { public string Name { get; set; } public int idCountry { get; set; } public string Country { get; set; } } And I have in the controller the following public ActionResult Register() ViewData["c...

ASP.NET MVC Dynamic Stylesheets

The project I'm working on allows an end-user to modify CSS code to integrate the application as best possible. Most of the CSS values are stored in a database and need to be retrieved and parsed dynamically. I setup a Style controller, and gave each stylesheet an action, and then passed the configuration data through to the View. I s...

Why is GetVirtualPath failing after upgrading to .NET 4

I have the following route defined: var route = new Route("{id}/{a}/{b}", new MvcRouteHandler()); route.Defaults = new RouteValueDictionary(new { controller = "Home", action = "Show" }); route.Defaults.Add("a", ""); route.Defaults.Add("b", ""); And the following controller code: public ActionResult Show(int id) { RouteValue...

Assembly references in Nhaml

I'm trying to get Nhaml working for an ASP.NET MVC 2 project. The backend of the project is Mongo DB, using the NoRM driver. NoRM specifies some custom types, particularly ObjectID as a reference to Mongo's unique _id column. I've got the Nhaml views compiling and outputting data from a strongly typed model, but it's choking on the Obje...

SelectList with MVC2 and custom ViewModel

I have created a custom ViewModel and one of the fields is a SelectList/DropDownlist. I wanted to use EditorForModel to display the ViewModel. All the fields work except the SelectList. I have tried a few different things and nothing has come up. I saw on one post that EditorForModel was not "smart enough" to do a DropDownList and I was ...

What is the difference between asp.net and silver light

I need to create an online car booking system. Which framework would be better for this purpose? ASP.Net or Silverlight? ...

ASP.NET MVC 404 handling and IIS7 <httpErrors>

Good day! I use strategy to handle 404 errors like this: http://stackoverflow.com/questions/3545906/error-handling-for-asp-net-mvc-2-and-iis-7-0 or this: http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc/620559#620559 In short: I handle 404 as exception in Global.asax without adding any routing ru...

How to localize MVC with database backed resources

I have read most of the literature Google and SO provides on this (correct me if I've missed something). What I am trying to do is to localize an MVC site using resources, I want the compiletime safety of strongly typed resource files (ResX) but the flexibility of the ASP.NET 2.0 Resource-Provider Model, or something similar to that. I ...

send email asynchronously in asp.net mvc 2

Hi I need to send email in asp.net mvc 2 asynchronously after a certain action is executed. i read this thread http://stackoverflow.com/questions/461361/asp-net-mvc-framework-automatically-send-e-mail Any further help is appreciated ...