asp.net-mvc-2

ModelState doesnt contains Form values

i have this view model: public class ItemMenuViewModel { public ItemMenu Item { get; set; } public IEnumerable<SelectListItem> Pages { get; set; } } for this view: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SIIMVC.Controllers.ItemMenuViewModel>" %> <%@ Import Namespace="SIIMVC.Models.Ex...

NHibernate, AutoMapper and ASP.NET MVC

I'm wondering about a "best practice" using NHibernate, AutoMapper and ASP.NET MVC. Currently, i'm using : class Entity { public int Id { get; set; } public string Label { get; set; } } class Model { public int Id { get; set; } public string Label { get; set; } } Entity and model are mapped like this : Mapper.CreateM...

Hidden field as a (re)CAPTCHA alternative in a ASP.NET MVC2 application

I am writing a "contact us" form on a web project that I am currently involved with. While I've used reCAPTCHA in the past, for this project, I would prefer not to clutter the interface with extra images, fields, etc. How many of you have had experience in adding a hidden field named something like "first_name" to your form. The ide...

asp.net mvc model inheritance for "simple forms"

How would you implement this ? I have the following model : class Something { public string Label { get; set; } public DateTime Date1 { get; set; } } class SomethingStage2 : Something { public DateTime Date2 { get; set; } } class SomethingStage3 : SomethingStage2 { public DateTime Date3 { get; set; } } And the ...

MVC - One Page different URL

Hey There I Have one view page, of which the content ain't always the same, ie: partial views are loaded on demand. What i want to achieve is: Allow users to create Virtual Pages (each with it's own url), but the pages must all point to that view. I hope i am making sence. Any idea's? I have already looked at: http://rebuildall.umb...

Unable to log Code 500 Errors in ELMAH

On my ASP.NET 4.0 MVC project running in IIS 7 I have set up and configured ELMAH to log errors on my site. However, I am unable to get any reporting on errors with code 500. I set up a simple controller that creates a divide-by-zero exception, but ELMAH does not log it. I can get ELMAH to log other messages just fine and I am not filt...

Return view from different area

Hello, I've got my ASP.NET MVC 2 application divided into few areas. One of them is a default area in main catalog, the other is Account area in Areas catalog. Now the problem is, that I need to use the same view in controllers from both of this areas. Now If they would be in the same area I will just return View("ViewName") and it's o...

ASP.NET MVC 2 Setting User Control element properties with values in the View Model

Hello, I'm not entirely sure this is possible, but what I am trying to do is set an element property within a user control to a value passed in via a ViewModel class. for example, say I have the following ViewModel class public class myViewModel { [DisplayName("Image URL")] public string URL { get; set; } and then have ...

Localizing Error Messages In ASP.NET MVC 2 (Default Validation Attributes)

Hey all ,,, i'm working on a multi language website and i want to localize the validation error messages for most of the ValidationAttribute such as [Requried] I know it can be done as Phil Haack have shown in this article. [Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "Required")] but i want t...

ASP MVC 2 Dynamic Href By Javascript

Here is the deal: My link: <li><% =Html.ActionLink("Scheme", null, null, null, new { @id = "schemeid" })%></li> JavaScript for changing href: <script> document.getElementById('schemeid').href= "Test/ALL"; </script> Its working in any browser on ASP.NET dev.server on vs2010; but when i host it on iis 7. it fails. and in source ...

ASP MVC 2 Javascript

I have code on javascript: <script>var index=0</script> How can i pass it to htmlhelper forexample i want something like: <%Html.ActionLink("test",'+index+',"Stations")%>'; but its obvious doesn't work; ...

Libraries for Social network integration features with ASP.Net MVC 2.0

I am developing a public website on ASP.Net MVC2.0 and I am looking for open source libraries for Social Network Integration that give me following functionality. User can share a page to their facebook, twitter, linkedin and other accounts Retrieving tweets from an account Facebook "like this" ...

Handling Errors In DDD-Flavored ASP.Net MVC2 Web Application

What are "best practices" concerning error handling in an ASP.NET MVC2 web app that is DDD designed? For example, let's take the most common aspect of a web app, the login: UserController: Obviously coordinates a few domain objects to eventually log in or refuse the user, and redirect to other parts of the web interface as needed. In m...

Asp.Net MVC application does not update files on web host?

I'm developing an MVC 2 application and have it on a web host. It works fine, but the strange thing is that when I update files, the updates don't "take". I can even delete an entire Controller file (just for testing the update problem), and it doesn't matter. I can still go to that page on the live site. That shouldn't be possible, but ...

Define EditorTemplate for child collection in viewmodel

I've got a model which contains a List of QuestionEditModel for which I want to use an EditorFor. Normally, I would just call EditorFor on the collection and MVC will do the rest. However, I need the individual QuestionEditModel to use different EditorTemplates depending on the value of a field within the object. I would've thought tha...

Find what class an abstract class is bound to in Ninject

Hi, How do I find what class is currently bound to the abstract class with Ninject in the following example: if(conditional) Bind<IProducts>().To<Products>(); else Bind<IProducts>().To<SqlProducts>(); Type currentType = 'Type based upon current binding of IProducts' How can I get the value of currentType. ...

Delete link with jquery confirm in Asp.Net MVC 2 application

I have a table with records that has delete links. Basically I followed the NerdDinner tutorial for that part in MVC. But I don't want to have the confirm view, I'd rather have a confirm dialog, and then if confirmed let the HttPost action method delete the record directly. I have something working, but being new to both MVC and jQuery,...

Debugging code in a view (asp.net mvc2)

Hello, How do I debug code in the View in asp.net mvc2 application? Edit after progress last night: Ok so now I have the following: in Shared\EditorTemplates\Equipment.ascx : <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DAT.Models.Item>" %> <% using (Html.BeginForm()) {%> <%: Html.ValidationSummary...

Html.Grid containing checkbox per row

Hi, I am using Html.Grid in my asp.net MVC2 application. The grid contains checkboxes per row. <%= Html.Grid<MyViewModel>(Model.MyList) .Columns( column => { column.For(x => Html.CheckBox("Select", false, new { id = x.ID })).DoNotEncode(); I need to loop through the checked records and action them. How can I ret...

Error handling for ASP.NET MVC 2 and IIS 7.0

Good day! I've recently switched from IIS 6.0 to IIS 7.x and I'm in search of error handling technique of my dream for ASP.NET MVC 2. What I want to achive: Handle all unhandled exceptions in one place (preferable in Global.asax handler) Custom handlers for 404 and 403 errors (both for MVC controller\actions and static files). These ...