asp.net-mvc

asp.net mvc jquery how to enable the button after disable

$("#btn").attr("disabled", "disabled"); i have used the above line to disable the button how would i enable it .this is not working $("#btn").removeAttr("disabled"); ...

Custom tokens in view engine?

In ASP.NET MVC 2 project, how might I go about writing a custom view engine that allows custom tokens to be used when searching for views? Specifically, I'm trying to achieve this: In PagesController: public ActionResult ViewPage(string folder, string page) { return View(folder, page); } I want the view engine to search for the vi...

RouteLink in HtmlHelper?

How can I make up a RouteLink in a custom HtmlHelper? I know how to make it in a partial view but I want to build up a new link in a custom htmlhelper extension method with the use of a RouteLink. How to accomplish this? Update: I noticed HtmlHelper.GenerateRouteLink. But what do I need to put in as parameters? ...

Bestpractice - Mixing View Model with Domain Model

Is it reasonable to mix view models with domain models? So i.e. the view model object contains some domain model objects (not the other way around!) ...

MVC omit optional page parameter

I have the following URL in mind: /restaurants/italian/miami.html /restaurants/italian/miami-p2.html Using these routes routes.MapRoute(null, "{category}/{branch}/{city}-p{page}.html", new { controller = "Branch", action = "Index" }); routes.MapRoute(null, "{category}/{branch}/{city}.html", new { contr...

Creating Database Mocks in ASP.NET MVC using Data from Existing Database

I have an existing ASP.NET MVC application with some sample data in the SQL Server database, which is working fine.. Assuming I have all of the necessary repositories and IOC in place, is there a tool that will extract the data from a group of tables, and "freeze-dry" it into a mock object (perhaps using an XML file to store the data)...

Is it possible to configure ELMAH entirely in code?

I'd like to configure ELMAH for an ASP.NET MVC site entirely in code. This includes registering the module, setting the logging provider and settings, and filtering exceptions. The only part I've managed to do so far is filter exceptions. Has anyone else figured out how to do this? I'd really like to avoid cluttering up my config file w...

ASP.NET MVC MOBILE Controller Route to Subdomain

I currently have an ASP.NET MVC application that exists. I want to add a small mobile friendly section to the site. I want to keep it extremely simple and integrate http://mdbf.codeplex.com/ into my project. Then on Home/Index check if the are mobile, then forward them on to the Mobile Controller (http://mysite.com/mobile/index). H...

Custom route & area in MVC 2

i'd like to map areas like this: /artists/{artistName}/images /artists/{artistName}/images/{imageId} /artists/{artistName}/blogs /artists/{artistName}/blogs/{blogId} /artists/{artistName}/albums /artists/{artistName}/albums/{albumId} in mvc2, how do i configure my area route and what does my file structure for my area view look like? ...

How to design configurable MVC panels?

I have to make a web application that produces pages that contain panels with different setting configurations for different sites the page is hosted under. For example, SiteA.com has a search panel with 3 select dropdowns and SiteB.com can have a search panel with 4 select dropdowns. Can anyone offer any advice on how I could proceed...

Is using something like the MvcContrib Grid a step backwards in code readability?

I mean, now we have all this movement towards separating your html markup from your code as much as possible using modern template engines (in the old days programmers usually just kept concatenating strings in php, which was terrible.) Then I look at a co-worker's code for generating an html table, and it looks like: <% Html.Grid(Mode...

Configuring XML-RPC behavior for IIS-hosted .SVC file?

I'm using Clemens Vasters' XML-RPC implementation to implement an XML-RPC endpoint. When I host the service in a console application, it works fine. I'd like to host it in an ASP.NET MVC application, so I'm using a .SVC file. This is partially working. When I browse to the .SVC file, I see the usual "You have created a service" stuff. ...

Cannot delete entity with ComplexType property (Entity Framework 4)

Hi everyone, This has been driving me nuts for a week now. I have a class that looks like this: public class SuggestionVote { public virtual int ID { get; set; } public virtual Suggestion Suggestion { get; set; } public virtual User User { get; set; } public virtual VoteTypeWrapper VoteType { get; set; } public virtual ...

asp.net mvc javascript server variables

I would like to send the following from JavaScript, because I am using Flash FSCommand to communicate between two views: Url.Action("Testing", new { FlashName = "flash.swf" } Testing is the view and Flashname is the variable I am using. The JavaScript should receive a command and arg from Flash movie.(e.g. command play with arg o...

Linq - SingleOrDefault and NerdDinner

Hi I'm getting into LinqToSql and using the NerdDinner tutorial. I'm trying to understand the syntax and would like to write out in more verbose fashion what is happening in the first line, which works. Question: How can I write the first query something like the commented out code (which doesn't work). public Dinner GetDinner(int...

How to get Controller name, and data avalible in a base Controller?

I have 2 questions. First, background: I have a PageController : Controller and SearchController : PageController PageController is defined as: public class PageController : Controller { protected ISite Site; protected PageConfiguration PageConfiguration; protected override void Initialize(RequestContext rc) { ...

Implementing jQuery AJAX calls in an ASP.NET MVC site

I'm building an ASP.NET MVC site where I want to implement jQuery AJAX calls in some places. I've read up on the subject, but still have a few questions. Model Binding First of all, what is the correct way to pass data through the AJAX calls and have it be model-binded into an object inside my Controller Action? So far, I've read in...

Anonymous Type syntax in ASP.NET MVC

Question: How could I rewrite the anonymous type syntax in the ActionLink to be a little more standard OOP? I'm trying to understand what is happening. What I think it means is: Creating an object with a single property id, which is an int, equal to that of the DinnerID in item, which is a Dinner. <% foreach (var item in Model) { %...

Can someone help me Mock this ASP.NET MVC Controller with Moq, please?

Hi folks, I'm trying to mock an ASP.NET MVC2 Controller using Moq but I get an error because i'm trying to mock an non-overridable property. How should I be doing this, please? NOTE: the controller I'm trying to mock up is the (abstract) ASP.NET MVC2 Controller ... not a custom controller. Why? I'm trying to test some custom controller...

Property-level validation errors hinder the validation of Class-level validation

Update after Bounty was awarded A new solution is coming up to this problem. Please refer to ASP.NET MVC 3 Preview 1 here: http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx Look in the section Validation Model improvements, where you will see the solution to my problem. Original Post Referri...