-
|
We just added a new dropdown list to one of our forms, which has a javascript function to change the background colour of a textarea. And the UpdateModel() on our controller class promptly fell over ... It turns out that UpdateModel() requires your class to have a property it can map for every form control with a Name(presuming you are using the lazy 'Request.Form.AllKeys')... or it throws an exception ... not the most helpful or obviously expected behaviour. Instead, use TryUpdateModel(), or use our quick fix to remove the ID from our dropdown as it wasn't needed. For binding that uses reflection, I would far rather the default behaviour was just to ignore the property ... this would allow views to be changed more easily without...
|
-
|
We just spent far too long on what turned out to be a stupid problem ... we kept getting an error telling us that the view did not inherit from System.Web.UI.Page ... unfortunately the guy who was working on the particular view and controller could not think of a specific change he had made to cause this error, and looking at the code didn't reveal one either. The problem was actually quite subtle, and quite stupid ... A short while before the developer had decided to change the view from being an ".aspx" to being a ".ascx", so removed the view from the solution, added a new view that was a UserControl, and carried on working. What he hadn't done was to actually delete the .aspx file, and even if he had done that...
|
-
|
In this series of blog entries, I build an entire ASP.NET MVC application from start to finish. In this entry, I integrate the Silverlight Media Player into the Family Videos MVC application so I can play videos. Before reading this blog entry, you might want to first read the previous two entries: Family Video Website #1 – Upload the Videos – In this entry, I create an MVC controller that accepts large file uploads. Family Video Website #2 –Add the Database – In this entry, I added a database so that I could associate additional information, such as a title and description, with each video. In this blog entry, I make two major changes to the Family Videos Website. First, I redesign the view that renders the uploaded...
|
-
|
Like many other nerds (sorry people, lets face we are nerds :) ), as soon as I heard that MVC Preview 5 had been released I wanted to run out and upgrade Dimecasts.net. Let me first start off by saying this. Anyone that decides to build a production application of any size on a Technology Preview must be willing to accept breaking changes between releases. Please do not take this post as me 'bitching' or 'complaining'. This post is just to help others that may be about to do the same thing. Here are the conversion issues I ran into: Issue #1: Since the new assemblies are now versioned again I needed to update the web.config to reflect 3.5.0.0 Solution: Spend 3 seconds changing the web.config Issue #2: The decision was made by...
|
-
|
Expecting it to be painless to move from Preview 4 to Preview 5 was probably hoping a little too much ... but it certainly wasn't the worst thing in the world. A couple of things did catch me that I didn't find in the notes for upgrade, so I thought I best post them in case someone else gets the same problems: BindingHelperExtensions.UpdateFrom has gone Yep, gone ... which was a bit of a pain. I understand many people are using other methods, and probably we should be too, but this was the simplest option and is now being used commonly here. In it's place it turns out that you can use: UpdateModel.From(model, Request.Form.AllKeys) this.ReadFromRequest has gone Another removal, the replacement is: Request["key"] LinkBuilder...
|
-
|
If you are trying to use the HTML Helper RenderPartial and you received the following error: CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments error do worry, you are not alone. When I was trying to upgrade DimeCasts.Net to Preview 5 I was getting this error. What was really odd, was that the exception and stack trace did not really make sense. It was not till I read Brad Wilson's blog did I realize what the issue was. Take a look at the following code: <%= Html.RenderPartial("somecontrol.ascx", SomeDataEntity ) %> What you will notice is that the code above has an = sign in the markup. I left this because I converted this code from Html.RenderUserControl which...
|
-
|
In this tip, Stephen Walther warns you to avoid making a mistake that can result in private data being displayed to unauthorized users. Imagine that you are building a financial services website. Each user of the website can log in and view a page that lists their current investments. For example, the investments page might show a report displaying how much you have invested in different stocks, bonds, and mutual funds. Now, imagine that your website becomes wildly successful. It is used by billions of users every day. Your website performance starts to degrade. Each time a user visits their personalized investments page, a complicated query must be performed against the database which makes the investments page slow. What do you do? Here are...
|
-
|
Looks like Scott Gu and company put out drop 5 of their MVC Framework. You can grab the latest drop from CodePlex . From taking a quick look at the Release Notes New Features Various Controller and Filter Improvements Removed the ActionMethod property from the filters Add an IActionInvoker interface for release the controller class from having first hand knowledge of the ActionInvoker Added various HelperMethod improvements Added the ability to register your view engine globally Modified the IViewEngine to add a RenderPartial for rendering partial views Breaking Changes Changed the IViewEngine interface Modified some of the HTML Helper methods Unannounced Changes It looks like that they removed the sealed keyword from many of the Attributes...
|
-
|
Improve the performance of ASP.NET MVC applications by taking advantage of the Velocity distributed cache. In this tip, I also explain how you can use Velocity as a distributed session state provider. The best way to improve the performance of an ASP.NET MVC application is by caching. The slowest operation that you can perform in an ASP.NET MVC application is database access. The best way to improve the performance of your data access code is to avoid accessing the database at all. Caching enables you to avoid accessing the database by keeping frequently accessed data in memory. Because ASP.NET MVC is part of the ASP.NET framework, you can access the standard ASP.NET System.Web.Caching.Cache object from your ASP.NET MVC applications. The standard...
|
-
|
In this tip, Stephen Walther demonstrate how you can create new LINQ to SQL extension methods that enable you to dramatically reduce the amount of code that you are required to write for typical data access scenarios. By taking advantage of LINQ to SQL, you can dramatically reduce the amount of code that you need to write to access a database. LINQ to SQL has given me back several weeks of my life that I would have otherwise wasted in writing tedious ADO.NET code. In short, I am a fan. However, LINQ to SQL is a general data access technology. It is not specific to ASP.NET MVC. You can use LINQ to SQL when building Windows Forms applications, console applications, or just about any other type of Microsoft application. For this reason, it is not...
|