asp.net-mvc

Dealing with ASP.NET MVC "tag soup"

I was working on an ASP.NET MVC template today, and after staring at all those fluorescent yellow % tags for long enough, I basically decided I had had enough, so I painstakingly modified my ascx file to look like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Model == null) { ...

How to Determine ASP.NET MVC 1.0 Validation State inside the View

I need to customize the validation message style. The way I am approaching this is to wrap the ValidationSummary helper with a styled div. The problem I have is that the div is visible even when there is no error on the page. Is there a way to determine if the ModelState has an error inside the view? Or should I approach this problem som...

ASP.NET MVC Multi Project Areas Questions with setup

Hello, For those who setup muli project areas in ASP.NET MVC 2 in VS 2010, I have a few questions for you: Can other project areas use one master page? Or does each have to have their own master page? What about the web.config file? Does each area need the config file? Or does it rely on the master? I tried removing the master page...

Storing Documents and associating Metadata

This question is somewhat related to this. I want to have document storage along with some complex metadata. I am not using sharepoint. I have a very simple directory structure that goes 2 levels deep. (One folder and documents underneath). I want to store metadata associated with each file....tags, popularity (# of times accessed), cre...

Set page scroll position on page load of MVC app.

Hi, I have a ASP.NET MVC app. How do I set the scroll position of a page on page load at a defined point? Can I do it with an anchor, if so how?? Malcolm ...

generic was used with wrong number of arguments error?

Does anyone know what on earth this is? i can't get it to go away. •model {"The generic type 'System.Web.Mvc.ViewUserControl`1' was used with the wrong number of generic arguments in assembly 'System.Web.Mvc... it happens when i call a newly constructed model that i pass to a partial view, and try using/calling some methods of it in the...

What are some key gotchas when working with Json responses?

I'm working on an ASP.Net MVC project and have been learning a few little tricks with JSON objects that made me scratch my head for quite a while. For example, ensuring that when I call $.getJSON() from jQuery, I actually need to make sure my JSON is returning an object, not just a string value (well, D'uh! right?). What are some of th...

ASP.NET MVC Instability

Hi there, Got a slightly odd one here. We have an MVC site that is experiencing some instability. Once a week for the last couple of weeks the site has gone down. We have found that all we need to do to bring the site back up again is 'touch' the web config file (i.e. open it and save it, with no changes). This brings the site back ...

Enable / disable session state per controller / action method

We are building an ASP.NET MVC application which will be deployed behind a hardware load balancer that supports, among other things, caching. Our proposal is to manually define which URL patterns should be cached by the load balancer. This will be quite an easy process for us as we have 'catalogue' pages which are relatively static, the...

how to call a javascript method after action or from a view?

i just want to be able to call a javascritp subroutine on the client, after the server has done its thing (when an action completes or control goes to the view, i'd dont mind calling the js from the view either). for some reason, even vs2010 doesn't let me put breakpoints in <% ... %> tagged areas between <script...> and </script> tagg...

get the current controller and action within masterpage

using asp.net mvc. I have various links in the masterpage. eg /Home/ /Home/About /News/ /Documents/ if i select a link i want a class set on it. e.g. if i select the News link I want to highlight it by setting a class on it. how can i determine what controller and action im in in order to set its class attribute? ...

how do i call a javascript subroutine from mvc server side code?

basically what the title says, i know you can return a javascript view but this has never worked for me. i couldn't find a proper tutorial or explanation about this concept either, if anyone can shed some light on it that would be great (yep, ive tried google countless times). thanks edit: ive used your tips, debugger etc... thanks gu...

how to show a modal Loading ... while a ajax request $.get/$.post is running ?

I have a web application in asp.net, mvc and sometimes my ajax request might take more than 1 second. So I need to show a big div over the entire page (Loading...) while this request is working and to hide it when it's finished. Does anybody know how to do this ? ...

Data Annotation Ranges of UK Datetime fields

I want to use Data Annotations to validate DateTime fields, but I'm running into problems. According to documentation on MSDN, the following should do the job [Range(typeof(DateTime), "1/2/2004", "3/4/2004", ErrorMessage = "Value for {0} must be between {1} and {2}")] However, this marks any date I enter as invalid! At first I th...

How to Load HTML Snippet returned from Handler call into a string?

Hi all I have an ASP.NET MVC application and I'm trying to load the following html snippet from a Handler in another ASP.NET project, from one of my controllers to display in a View: <br /> <div id="ctl00_divCommentary" class="commentary"> <div id="ctl00_divCommentaryHeader"> <span id="ctl00_lblCommentaryHeaderBold" class="...

enforcing ObjectStateManager entry deletion on page leave

I have a edited RESTful wizard based upon Shoulders of Giants | A RESTful Wizard Using ASP.Net MVC… Perhaps? . This wizard has a CANCEL button which, when pressed, fires the code below. // If the user cancels, drop out altogether if (!string.IsNullOrEmpty(CANCEL_BUTTON)) { Session.Remove(VACANCYWIZARD_SESSION_KEY); repository...

Generating Admin Interfaces in ASP.NET or ASP.NET MVC

Is there a Django-like admin interface generator for ASP.NET or ASP.NET MVC? If not, are there any tools that could assist in creating one? ...

Should validation rules always be enforced at the model level?

With the new ASP.NET MVC 2 validation features, we can decorate the properties of our domain model objects with DataAnnotations attributes that describe criteria for valid values. The DefaultModelBinder knows about this and populates ModelState.IsValid accordingly before a controller action is invoked. Since the validation rules are defi...

Problem deploying an ASP MVC application to IIS7

I've got an ASP MVC (1.0) application. It works fine locally via visual studio and on our dev server which runs IIS6. But when I try to deploy to the Test server (running IIS7 on Windows Server 2008 R2) I get only : "Could not load file or assembly '<ApplicationName>' or one of its dependencies. Access is denied" (where <ApplicationNa...

asp.net mvc custom exception filter to force a return of full view, not partial...

I have a custom exception filter that I'm calling by virtue of adding a [CustomExceptionFilter] attribute to my class. It works as I'd like it to, however if the action method is returning a partial view (through an ajax request), the exception (which is basically a redirect to a not authorized page), is loading up the partial view with...