asp.net-mvc-2

How do I test for TempData being set in MVC 2 where there is a redirect?

When trying to test my MVC 2 controllers, I am having a hard time testing the result of TempData when I'm doing a redirect. It works ok if the result of the controller action is a ViewResult, however, in a redirect, it is RedirectToRouteResult. So my test is something like this: var controller = new SubscriptionController(this.dataSto...

Html.EditorFor() -- editor template in portable area

I am trying to use a partial view editor template in my application using the Html.EditorFor method in my view. If the editor template is directly in the Views/Shared/EditorTemplates directory of my application, it works great. If the editor template in the Views/Shared/EditorTemplates directory of the portable area I am using in my ap...

Tell C# to use Castle to create objects

Hi! I think my question is a long shot. Lets say I have an attribute: public sealed class MyCustomAttribute: ActionFilterAttribute Used on a class method [MyCustomAttribute] public virtual ActionResult Options(FormCollection collection) Now, I need to add a contructor's parameter public MyCustomAttribute(IMyDependent...

Why is my static class not being initialized in ASP.NET MVC?

I have a ASP.NET MVC project that has a static class in it to initialize some AutoMapper mappings: static class AutoMappingConfiguration { static AutoMappingConfiguration() { SetupMappings(); } static void SetupMappings() { AutoMap.CreateMap<Product, ProductDTO>(); // more mappings } } ...

ASP.NET MVC Object reference not set to an instance of an object

I saw a similar question here on SO but I believe mine differs a little a bit. OK, so I have a simple view here: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<RootFinder.Models.QuadCalc>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Po...

ASP.NET quadratic calculation returning NaN erroneously

My ASP.NET MVC web application is supposed to calculate the roots of a second-degree polynomial (quadratic) but I'm erroneously getting Nan responses. I believe this is due to my improper setup, so let me post some of my code here: View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.M...

Unity 2 trouble referencing RegisterInstance using InjectonProperty

I have the following code: Unity Container: Settings settings = CreateSettings(); container.RegisterInstance(settings) .RegisterType<MyHttpHandler>(new InjectionProperty[] { // How do I tell Unity to inject my settings created above? new InjectionProperty("Settings", new Resolved...

ASP.NET MVC2 DRY view pattern?

So, I put all this logic in my view, thinking it would be helpful to follow the DRY principle. Basically, this replicates a paper form, and in my view model, I have pairs of properties named like XXXCondition and XXXComment which put together form an InspectionDetail in my actual model. <table> <% string secname =""; fo...

i have been working on asp.net MVC ,unable to fire on change event in dropdownlistbox

I have created a controller by name AdmissionControlller there I have added two ActionResult functions: Create and Post Event // POST: /Admission/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here return RedirectToAction("Index",collec...

Permission Sets for Roles in ASP.NET Membership Provider using MVC 2.0 - Help

I am planning to write a Role Base Access Control Mechanism. What I thought is to have a set of permissions, which can be associated with each role. Normally Membership provider comes with normal roles and its details not with Permission sets. Roles with permission can be assigned to the new users. Permission Sets to Roles will give m...

ASP.NET MVC 2: How to accomodate ValidationAntiForgery token AND use UpdateModel with posted JSON?

So I'm using ExtJs to post JSON for updates and creates to my ASP.NET MVC 2 application. I'm also using the ValidateAntiForgery attribute which only works when a POST is made. Question is: Can I use model binding in this scenario and if so, how? Here is an example of what the JSON looks like when I attempt to update a 'Company' entit...

displaying validationSummary message in div element in asp.net mvc 2.0

I am doing validations in registration page.My requirement is if ValidationSummary error message is generated i,e,ValidationSummary is become true then i have to display that ValidationSummary message in that div element.If error is not generated then that div element is not visible. So i have to check whether Validationummary is true t...

Could not load type 'System.Web.Mvc.ViewMasterPage<dynamic>'.?

I am deploying a Asp.Net MVC 2.0 application on IIS 6.0. When I request any page I get the following error. Parser Error Message: Could not load type 'System.Web.Mvc.ViewMasterPage<dynamic>'. Source Error: Line 1: <%@ Master Language="C#" Inherits= "System.Web.Mvc.ViewMasterPage<dynamic>" %> Line 2: <%@ Import N...

C# ASP.NET MVC2 Routing Generic Handler

Hi, Maybe I am searching the wrong thing or trying to implement this the wrong way. I am dynamically generating an image using a Generic Handler. I can currently access my handler using: ImageHandler.ashx?width=x&height=y I would much rather access my handler using something like images/width/height/imagehandler Is this possible t...

recursive function for hierarchically data

my model using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace amief.Models { public class WebsiteModels { public static void getPagesForPage(int pageId, dbDataContext db, List<page> myPages) { var pages = (from p in db.pages where p.pageParent == ...

limiting the no. of characters entered in textbox html helper element in asp.net mvc 2.0

I am using a order form as follows, <%using (Ajax.BeginForm("AddToCart", "../ShoppingCart", null, new AjaxOptions { OnSuccess = "handleUpdate", OnBegin = "ajaxValidate" }, new { @class = "AddToCartForm" })) { %> <%=Html.Label("Quantity")%> <%=Html.TextBoxFor(model ...

Why is EditorFor in my ASP.NET MVC 2 application throwing ArgumentNullException?

I have a weird problem with EditorFor in one of my views. The following code throws an ArgumentNullException. <%: Html.EditorFor(x => x.Name) %> However, the following code is fine. <%: Html.TextBoxFor(x => x.Name) %> Model.Name is a string variable - and it's set. EditorFor works in another view - until this view crashes, at whi...

validating the checkboxes when its parent element is visible

I have one critical issue .I have a dropdown list and a list.within that list I have many checkboxes for property size.Now I want to validate in such a way that, if I select apparel item in dropdown list then list containing the checkboxes should be visible .so user has to select select(checked) one checkboxes.If he select Non-apparel it...

ASP.Net MVC 2 - button click on view is not calling any method in the controller? what am i missing?

Am trying my hands on asp.net mvc2 and using mvc2 template to work upon. Following the template, i created my own model, controller and view in there respective folder locations. i also changed the default routing in global.asax for this controller and view. now my view is getting loaded but when i click on a button in my view, none of t...

datetime2 and ProviderManifestToken in Entity Framework

I have an MVC app using Entity Framework and a SQL 2008 DB. I used the EF wizard to generate my data model. I have a SQL table with a standard SQL DateTime column. The EF model is using System.DateTime. But when I try to insert a new record into this table from my application, without specifying a value for this DateTime column, I ge...