asp.net-mvc

Can you use ASP.NET MVC UpdateModel() with complex Model Object containing List<T> while attempting to include (white list) and/or exclude (black list) certain fields?

Hi, I've seen articles and blog posts indicating what I am attempting to do should be supported; however, I have been unable to get it working so hopefully someone can confirm that it does/does not work and/or tell me what I am doing wrong. I have a "complex" model (Invoice containing a List of InvoiceItem) that I am attempting to bind...

What techniques work for abstracting session in ASP.NET MVC and maintaining testability.

I'm currently working on a large scale ASP.NET MVC application and one area where testing is failing is around things that we're storing in session. My first pass at abstracting session is just to create a very simple static class and make all calls to session go through that. So I might have something like this: public static class A...

Multiple controls in MVC view that modify same model value

I have a field in my model - call it 'distance' - and I want to write a view that contains both a checkbox and a textbox. If the checkbox is checked, the textbox becomes disabled and 'distance' gets the value 0 when the form is submitted. If the checkbox is not checked, 'distance' gets whatever value is in the textbox when the form is...

Should I neccessarily have a PK on the source table to create an ADO.NET Entity Data Model?

I'm trying to "Entitify" some external table (which I don't administer) in order to use it within a MVC application and in principle I'm not being terribly successful with the attempt (VS2008 output): Error List [0 Errors] [0 Warnings] [1 Message] Description The table/view 'DATABASE.dbo.table' does not have a primary key defined and ...

Passing Parameters to jQuery Delete Button Click EventHandler

I have the following jQuery $('#btnDelete').click( function() {//Do the delete here via jquery post}); In my table I have numerous rows with the following <a id="btnDelete">Delete</a> How I do I pass parameters to the click event to post an ID to delete something ...

Repository in Controller or Model?

I've been working through the NerdDinner Tutorial and most of it makes sense. What I'm not sure about is why the Repository is used directly in the Controller and not the Model objects. For instance, if we wanted to implement our own membership system and it had an AccountController with a Login method, what would be the best solution fo...

How to architect for enhanced functionality with Javascript?

I'm building an application using ASP.Net MVC, and I want/need it to work with and without javascript enabled. The first stumbling point for me is this: When the user clicks on the register link, if they don't have javascript enabled they should be sent to a registration page that has master page stuff around it... but if they do have ja...

MVC - How to structure views for a search form with results on same page.

Hi, I have MVC 1.0 app on VS2008. I have webpage that has a search form fields and then when search button clicked uses Ajax.BeginForm to load results in a div. Works great! But the results have a pager that just uses an anchor with href passing in page index to controller action. Of course the same action that is used when the sea...

Where can I get Entity Framework from?

I am sorry this is perhaps a really stupid question. Forgive me because I come from a Java background and I am making an effort to learn .Net technologies. I am trying to follow the tutorial for an ASP.Net MVC website from their website and I get to the part where I need to make a new model. When I right click they say I must choose ADO...

What should I be using with ASP.Net MVC, NHibernate, LINQ, EF?

Hi I posted a question a little earlier and I had some replies that I should look at some different technologies. Which of the above (or other feel free to mention) is the most popular or best supported. As stated in my earlier question I am learning ASP.Net MVC. I come from a Java struts background but I am prepared to try and learn wh...

Using ASP.NET MVC and JQuery how do I run a JS function for each item in a list on load?

Imagine a view that is designed to show a list of items of type Foo: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Foo>>" %> Now the page displays the list of items of type Foo: <table> <tr> <th> Name </th> ...

Will IoC lead to too many params for ASP.NET MVC Controller constructor?

I have decided to use ASP.NET MVC for a website project and want to follow some of the best practices being written about. So, I have separated out the Domain/Model into a separate project, created IRepositories and concrete repositories and have now turned my attention to Castle Windsor as the IoC. The problem I now face is that for a...

Options for handling postbacks in ASP.NET MVC

Currently the way I am handling postbacks in ASP.NET MVC is to grab the input variables using: string username = ""; if (null != Request["username"]) username = Request["username"].ToString(); I then would run a regex on the variable to ensure it was valid. Is there any other method for doing this? ...

Asp.net mvc - Accessing view Model from a custom Action filter

I am trying to access the Model data passed to the view in the action filter OnActionExecuted. Does anyone know if this is possible? I am trying to do something like this: public override void OnActionExecuted(ActionExecutedContext filterContext) { //get model data //... sitemap.SetCurrentNode(model.Name); } Any advice? ...

Render view as string then redirect.

In my ASP.NET MVC application, I would like my controller action to render a view to a string, send an email using that string as the body, then do a redirect. I've found several articles here on SO and elsewhere on how to render the view to a string. That part was easy. But when I attempt to perform the redirect, I get an HttpExceptio...

ASP.net MVC : IS this pattern reasonable or conceptually incorrect?

My controllers turn over the request to the appropriate service. The Service then makes calls to various Repositories. Repositories use Linq to Sql Entities purely for DataAccess and then map and return as Domain Objects. The service then decides what the Controller will present and replaces the DO with Presentation objects which are ret...

Can I get an ASP.MVC route from a url?

I define routes in my global.asax, like this: routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); Given a url: /somecontroller/someaction/3 is it possible to determine which route this will map to, and get the corresponding route object, with name, url temp...

Asp.net MVC spring bootstrapper

Hi, I am trying to create a bootstrapper with a tasks (for now RegisterRoutes and RegisterControllerFactory) defined in a Spring.Net container. The bootstrapper code is below: public static void Run() { IApplicationContext applicationContext = WebApplicationContext.GetRootContext(); IDictionary bootstrapperTasks ...

How to implement a custom cache provider with ASP.NET MVC

I am migrating a MonoRail application to ASP.NET MVC 1.0. In my original application I wrote a custom cache provider (a distributed cache provider using memcached). In MonoRail this task was very easy because the framework used interfaces and there is ICacheProvider that looks like this: public interface ICacheProvider : IProvider, IMRS...

How Do I Use Entity Object Navigation Properties In A DropDownList On My Strongly Typed ASP.NET MVC Create and Edit Views?

I've got an Entity Data Model with Product and Family types. Each Product has one Family. I'm using this model with an ASP.NET MVC web site. I want Family DropDownLists on the Create and Edit Views of my Product controller. How Do I Use Entity Object Navigation Properties in a DropDownList on my Strongly Typed ASP.NET MVC Create and ...