Browsing Tag »CodeDom«

Debugging ASP.NET generated code

February 4, 2010

This post applies to any ASP.NET app that uses .aspx files, whether WebForms or MVC. When you write an aspx/ascx/master file (I’ll just say aspx for here on, but it applies to all), it gets compiled dynamically by the ASP.NET runtime.  Note that this is true whether you use a Web Site or a Web Application Project (WAP).  While in a WAP, most of the code is built by Visual Studio, the aspx pages themselves are always built dynamically . Normally, when you work with aspx files, you only need to worry about what you write in there, and the specifics of what ASP.NET generates under the cover are somewhat of an implementation details.  However, in some cases it’s pretty useful to look at the generated code, either to learn exactly...(read more)

Take your MVC User Controls to the next level

January 13, 2010

Note: this is based on ASP.NET MVC 2 RC , and will not work on earlier builds.   The quick pitch: make your User Controls as cool as built-in render helpers! The goal of this post is to show you how to change the way MVC user controls are called from something like this: <%= Html.Partial("~/Views/Shared/gravatar.ascx", new { Email = "foo@bar.com", Size = 80 }) %> To something that looks just like a built-in render helper (like Html.TextBox(…)): <%= Html.Gravatar("foo@bar.com", 80) %>   The current model for User Controls in MVC If you have used ASP.NET MVC, you probably know that you can use User Controls (.ascx files) to provide partial rendering. For example, the default MVC app has a Site...(read more)