asp.net-mvc-2

How would you implement a category structure like dmoz.org

I don't have a problem with building the category structure. I have a problem trying to figure out how they included similar or other categories similar to a given one. For example, if you choose the "computers / software" category you will see a category for consumer information, games, sports, home etc. These categories don't belong di...

What's the Proper way to read/pass querystring values to a view in MVC2?

my url is working correctly as i can step into the controls correct method but..how am I to read the state name from the url into the view? My url: http://localhost:10860/Listings/Arizona/page1 My view: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/NestedSiteMaster.master" Inherits="System.Web.Mvc.ViewPage>" %> <h2...

ASP.NET MVC 2 - How to override an annotation for a single controller action?

I have a BaseController that all Controllers inherit from. The CaseController has the [Authorize] annotation, so that all controllers require authorization. But I've just realized that one single controller action must not require authorization. How can I turn off [Authorize] for just that one controller action? using System.Web.Mvc;...

Can you add dynamic validation attributes in Asp MVC 2.0?

I realize that I can simply add the [Required] attribute to a class property and MVC will automatically do validation in a very nice way. What I would like to do however, is assign the attribute at run time, is this possible? For example, say I have public class Cert { public string MedicalNum { get; set; } public int Cer...

automapper + lazy loading + mvc contrib grid + s#arp repositories

Hi, I am using the nice s#arp repositories and the paging extension method plus sorting like this: public ViewResult Index(int? page, GridSortOptions sort) { ViewData["sort"] = sort; if (!string.IsNullOrEmpty(sort.Column)) { return View(this.LabService.GetAllLabs().OrderBy(s...

Dynamic creation of models - entities using Asp.Net MVC

So, i have my database sorted like: Products_001 Products_002 Products_003 Let's say, if a customer logs in and his id is 001, he is only entitled to use the database-table products_001. Can i dynamically create his model - entity using Asp.Net MVC, and how would i do this? ...

SparkViewEngine spontaneous NullReferenceException while rendering view

We are using the latest stable release of SparkViewEngine for www.stribe.nl. There is a problem that occurs -sometimes- while rendering the homepage. When you look at the homepage it will usually render perfectly fine, but i noticed some exceptions in the EventLog from people visiting the homepage. The exception message is "Error execut...

how to invoke an event after losing focus from a textbox, asp.net mvc

I have two text boxes A, B using (Html.textboxfor). TextBox 'A' is enabled and TextBox 'B' is disabled. When I type values in Textbox 'A' and click outside( moving out the cursor from the textbox), TextBox 'B' should be populated with somevalue. For example : iam entering value of TextBox A = "King", if the focus is lost from the box,...

Asp.Net MVC Ajax refresh of table contents

Currently I have a table on my page which I need to refresh using Ajax. I was intending to render the table in a partial view and then just call an MVC render-partial update, which would have been nice and simple. However, I've since added a bunch of sorting/filtering controls in the header of the table. I would now like to refresh the ...

Inconsistant IE8 ajax post success from MVC2

I am getting an incosistant error in IE8, it happens about half the time. I have cascading drop downs using ajax to fetch the next select box options. $(function () { $("#stock_item_id").change(function () { var stock_item = $("#stock_item_id > option:selected").attr("value"); $.ajax({ type: "POST", ...

C#, ASP.NET MVC / MVC2: Add wildcard route for specific controller - help building route

Hello, lets say I have a controller named Store. There is an index method: public ActionResult Index(string val, long? id, int? id2) { return View(); } I want to fetch things like: /my-store/some-text /my-store/some-text/ /my-store/some-text/123456789012335 /my-store/some-other-text/4562343462345 /my-store/some-other-bla-text/456...

Unit Testing with Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model

I'm trying to get my head around using Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model. Let's say I have have a ProductsController instantiating a SqlProductsRepository class. public class ProductsRepository : IProductsRepository { public MyDbEntities _context; public ProductsRepository() { _context = new My...

Error using 'EF Tracing Data Provider'

I am Trying to incorporate 'EF Tracing Data Provider' into an existing MVC2 app using VS2010, .NET 4.0 in order to log all SQL commands. I have no interest at this time in the Caching provider. I beleive I have followed all the steps listed in the blog posting. BLOG POST My project does compile without error, however when I attempt to r...

MVC 2 UpdateModel on Interface, Should ModelBinderAttribute be ignored?

I have forms posting data from instances of a particular abstract class: public abstract class IRestriction { public string Name {get; set;} public abstract IModelBinder GetBinder(); } The concrete type and PartialView are determined at runtime: IRestriction restriction = (IRestriction)Activator.CreateInstance(Type.GetType(re...

Getting the Current controller and action sent to the Route

Hello, I am attempting to Get the current controller and action being called in the route. In my Global.asax.cs I have the following using and the following line: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using IProwlAdminUI.Models; *** LINE WIT...

Moq controller tests with repeated setup

I am getting started on the Moq framework and absolutely love it. I am writing some controller tests that have several services and interfaces to Arrange my controller for the test. I'd love to modularize it a bit more, and thought this would be a trivial task, but it turns out to be a bit trickier than I thought. Here is one simple un...

Associating multiple OpenID's to a single user using the built in ASP.NET providers

I've configured a new MVC2 site to use JanRain Engage (formerly RPXNow) for authentication. I would like to be able to associate multiple OpenID's to a single user account, but still use the built in providers. Is there a good solution for handling this without creating new tables or heavy modification to the built-in stored procs? Po...

Session is NULL when running ASP.NET MVC inside of ASP.NET

If I create an ASP.NET Web Application project and then add an ASP.NET MVC 2 to it using the default routes defined like so routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { action = "Index", id = UrlParameter.Optional } ); The Sessi...

Passing the model in a view back to an action

Hello, I am wondering how I can pass a model back to an action so that I can continue to work on the data but in a different action based on the button's pressed To send it back, I specify the Control, Action and use the new { dom = Model } to specify the parameter. dom is a List (so a list of domain objects. My model passed in is an ...

Ajax Partial Update with Partial View not working in ASP.NET MVC2

Hi, I've ran into some trouble trying to get partial updates to work in ASP.NET MVC2. (I think) I followed the tutorials I found online pretty closely, but the Ajax part isn't working. The controller does what it's supposed to do without errors, but the page doesn't update itself. When I refresh the page I can see the result of my actio...