Articles : Page 1 of 1
-
Adding Export Capabilities to the Razor WebGrid
Sep 1103When MVC first came out I really missed having a grid control. Now a few years later, we finally have a grid control again. In case, you didnt know the WebGrid was included in the System.Web.Helpers assembly which shipped with MVC 3. After using a variety of grid controls over the years I was actually glad that the API for the new WebGrid was kept clean and simple. Here is a screenshot of what the grid looks like: To display a grid on a razor view page, you basically create a new grid objec...
-
Studio for Wijmo MVC Review
Aug 1122I was recently asked to review Studio for Wijmo MVC by Component One and, overall, I am impressed. There are 2 major components of this. The first is Wijmo Complete which is a collection of over 30 UI widgets (very similar to jQuery UI). The second is Wijmo Scaffolding for MVC which builds upon the scaffolding that was released as part of the MVC 3 Tools Update (note: is does *not* build on top of powershell-based MVC Scaffolding which Microsoft released earlier this year). Some of the Wijmo...
-
How to access controller methods from a view in ASP.NET MVC
Jul 1130This question has been posed in several places. One of the places is on StackOverflow here. The use case here is that my controller has important state or an important function, and I’d like to leverage it from the view. It’s not appropriate to factor out to an html helper or other view-based utility class. It is something unique to the controller. It would be very easy to just pass the controller over to the view so that the view could make use of its methods, but there is a lot of discussion...
-
Changing Base Type Of A Razor View
Feb 1121Within a Razor view, you have access to a base set of properties (such as Html, Url, Ajax, etc.) each of which provides methods you can use within the view. For example, in the following view, we use the Html property to access the TextBox method. @Html.TextBox("SomeProperty") Html is a property of type HtmlHelper and there are a large number of useful extension methods that hang off this type, such as TextBox. But where did the Html property come from? It’s a property of System.We...
-
MVC 3 AdditionalMetadata Attribute with ViewBag to Render Dynamic UI
Jan 1131A few months ago I blogged about using Model metadata to render a dynamic UI in MVC 2. The scenario in the post was that we might have a view model where the questions are conditionally displayed and therefore a dynamic UI is needed. To recap the previous post, the solution was to use a custom attribute called [QuestionId] in conjunction with an “ApplicableQuestions” collection to identify whether each question should be displayed. This allowed me to have a view model that looked like this: ...
-
Mixing Razor Views and WebForms Master Pages with ASP.NET MVC 3
Jan 1125I've spent the last few weeks travelling around presenting WebMatrix, Razor and ASP.NET MVC 3 to folks. Many people have existing WebForms apps or MVC apps with WebForms Views. The question has come up a number of times, Can I mix Razor Views and WebForms Views in a single ASP.NET MVC application? The answer is, No, Yes, and Maybe, But It's Not Supported. Most commonly the scenario is that someone has an existing WebForms (ASPX) Master Page that works nicely, and they now want to include...
-
ViewBag in ASP.NET MVC 3 - Dynamic Wrapper Around ViewData Backing Store
Jan 1119ViewBag is another way to access the backing store used by ViewData....
-
Dynamic Methods in View Data
Aug 1002In ASP.NET MVC 3 Preview 1, we introduced some syntactic sugar for creating and accessing view data using new dynamic properties. Sugar, it’s not just for breakfast. Within a controller action, the ViewModel property of Controller allows setting and accessing view data via property accessors that are resolved dynamically at runtime. From within a view, the View property provides the same thing (see the addendum at the bottom of this post for why these property names do not match). Disc...
- 1

