asp.net-mvc

AutoMapper - How to pass parameters into a Custom Resolver using ConstructedBy method?

In my ASP.NET MVC 2 (RC) project - I'm using AutoMapper to map between a Linq to Sql class (Media) and a view model (MediaVM). The view model has a SelectList property for a drop down in the view. I have a custom value resolver to populate the SelectList property items from the db, but am wondering if there's a way to pass a couple value...

How to render an action link with an image?

I know to use Html.ActionLink() to render textual <a href..."> links to actions. How do I render a link to an action that has an underlying image as the link? <a href="foo"><img src="asdfasdf"/></a> ...

ASP.NET MVC: The best way to return type to a AjaxRequest?

I have Multiple ActionResults in my Controller. Almost all of them process either AjaxRequest and normal requests, dependending on the request (duh!). The point is, if I'm adding something to the database using an AjaxRequest, I just want to return a OK or ERROR (or 1 or 0, etc..) to my page instead of a View() or a ParcialView() because...

Custom Exception Filter not being hit in asp.net MVC

I have a custom exception filter that I'm using to catch a custom exception that I wrote but for some reason when I throw my exception, it's not ever getting to the filter. Instead I just get an error that my exception was not handled by user code. Can anyone please provide some advice/assistance as to how I should have this set up? R...

AJAX and Client-Server Architecture with JavaScript

I have to program websites, but I rather don't like the static HTML nature. I prefer more of a client-server architecture. Now I've figured, that with XMLhttp, you can basically dynamically update your page and send/request for information/action to/from a server. So this would basically cover the client area. But to complete a client-...

ASP.NET MVC Is it possible to use ascx files across multiple views with different Models

Hi All, I am wondering if it is possible to wrap up an ascx file so that it can be used in different views, without having to type it to a specific Model. This would mean you could use one ascx file for many pages, as long as the relevant model data was passed in. Currently I'm duplicating my ascx files for different parts of the site...

MVC Model Validation Programmatic Registration support

Today (15th Jan 2010) Scott blogged about the ASP.NET MVC2 model-validation http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx Anyone knows how can someone add validation rules at runtime programmatically ? "Programmatic Registration" is a similar functionality supported by ValidationAspects // regi...

Where to put a ViewModel factory in my ASP.NET MVC app?

I have a fairly complicated ViewModel associated with a product listing form, which has a lot of custom default values depending on the currently logged in user. I'm finding that populating it in my controller is quite a chore. So I'm thinking of creating a factory class for it, but I'm wondering where in the project structure it would...

Asp.NET MVC Redirect not working

The following examples are redirects wich we're trying. The first one, for user login, works, after that no redirect works. I have no idea about what may be the cause, tried redirecttoroute too, it is like if the server wasn't sending the headers or anything. I have no sniffing software to check this out. UrlHelper uH = new UrlHelper(ne...

Strongly-typed partial view is not loading from jQuery function on radio button click

Hi I have two strongly-typed partial views (Developers list and Testers list) and the respective views are Developers.ascx and Testers.ascx Now I want to load one partial view based on the radio button selected. The below code is not loading the URL that I specified on radio button change. Code Snippet: $(':radio').click(function() ...

binding fields in a dialog popup in my view

i have an html table in my asp.net mvc view an i am running into some real estate issues with screen space. I think in one area of my view i am going to have a button in a column of an html table that says "Details" which, when clicked, loads up some dialog ui. what i am trying to get my head around is that i want the fields in the d...

Is it possible to use OutputCache on mvc JsonResult controller methods?

I am trying to do this, and it leads to result with contentlen 0 It looks like: [OutputCache(Duration = 36000)] public JsonResult GetFileClasses() { return this.Json(TopicConfig.FileExtensionsSettings.List) } Any ideas? ...

Caching user data to avoid excess database trips

After creating a proof of concept for an ASP.NET MVC site and making sure the appropriate separation of concerns were in place, I noticed that I was making a lot of expensive redundant database calls for information about the current user. Being historically a desktop and services person, my first thought was to cache the db results in ...

The thread 0x1428 has exited with code 0

Hi guys, quick question, I get this message sometime in the output window in debug mode when running a .net mvc c# application. The application still works after these messages, it does not crash and there is no reason to crash, any ideas on what this mean? ...

trigger change event in cascading dropdown

I am using cascading dropdown from http://stephenwalther.com/blog/archive/2008/09/07/asp-net-mvc-tip-41-creating-cascading-dropdown-lists-with-ajax.aspx. I need to set a value to the dropdown, and call the change event, so that the cascading dropdown doesn't looks blank for the first time. But the change event is not calling with the t...

ASP.NET MVC custom user roles/profiles

Hi, I am creating a website using asp.net mvc model. When you crate and mvc application asp.net automatically creates roles/profiles for user and admins (as far as i know) and corresponding tables in sql server database. I a need a new profile/role names "sponsor" that has all the benefits of users/admins (like authorization etc). Is ...

ASP.net MVC Get only the selected rows (checkbox)

We are using asp.net mvc and having trouble in selecting the list of approved orders. the orders are approved by selecting the checkbox against each order. eg.. Order id Product Is Approved 1 book (depends if the user selects checkbox or not) 2 pen (depends if the user selects ch...

Asp.Net MVC Utility Controller Action for filtered dropdown lists...

I was thinking of creating a UtilityController that only contains actions which return json because I might have several forms with a province/state dropdown and a country dropdown. These dropdowns are filtered by selection with ajax...only show prov/state in selected country. What do you think about this idea...is it good...bad...neith...

ASP.NET MVC 2 AJAX dilemma: Lose Models concept or create unmanageable JavaScript

Hi, Ok, let's assume we are working with ASP.NET MVC 2 (latest and greatest preview) and we want to create AJAX user interface with jQuery. So what are our real options here? Option 1 - Pass Json from the Controller to the view, and then the view submits Json back to the controller. This means (in the order given): User opens some Vi...

Would using jQuery to load elements affect SEO ranking?

I have a page that has two parts that are slower loading. As they are already ASCXes, it would be trivial to render them asynchronously with jQuery. That would mean, obviously, that the content in question isn't pumped to the browser on the first trip, but rather 200ms or so behind it. Do the spiders evaluate the content that loads via...