William Duffy

Glasgow Based ASP.NET Web Developer

Post archive for ‘MVC’

Repopulate Html.PasswordFor<> on validation errors

ASP.NET MVC’s HTML helpers are fast and efficient for rendering elements using your model. One of these is the HTML.PasswordFor<> method, which has a little gotcha that many people get caught out with.
The HTML.PasswordFor<> method will render a password input to mask keystrokes on the browser but will not populate the value using the model. [...]

RssResult - An ASP.NET MVC RSS ActionResult

One of the most common tasks for data serving websites is offering an RSS feed that users can subscribe to in order to keep up with the latest updates to that data.
Previously I posted the article Creating a simple RSS feed using ASP.NET MVC which demonstrated how to create an RSS feed in a quick, [...]

CSS class property in ASP.NET MVC HtmlAttributes

When adding an ActionLink or using a similar Html helper on your C# ASP.NET MVC views you will on occasions want to pass a css class via the htmlAttributes parameter. As this is normally achieved by creating an anonymous type you may expect the following code snippet to work.

1
<%= Html.ActionLink("My Link", "MyLink", null, new { [...]

Creating a simple RSS feed using ASP.NET MVC

Looking to serve an rss document via your ASP.NET MVC controller? Here is a simple, quick means to do so. If you are looking for a much neater, smarter, reusable method of serving rss from your controllers check out my ASP.NET MVC RssResult post (coming soon).
For the demonstrations below I will be using a generic [...]

ASP.NET MVC root url’s with generic routing

Normally, the url to handle a contact view would look similar to /Home/Contact. I’m really not keen on that and wanted my top level view’s url to look like /Contact. This in itself is easy enough, you just create a route {action} and set that routes default controller value to { controller = “Root” }. [...]