Server controls

Reducing viewstate on custom controls on 01 Feb 09 (Add comment)

One of the biggest waste I see in using viewstate is that it persists values that are already set in the aspx. These get set every time that the page runs and don’t need to be round tripped to the browser so that they will be persisted. I did a little experiment a while back […]

Saving server control properties to ViewState with custom attributes on 13 Aug 08 (6 comments)

Use custom attributes to take the tedious work out of creating server control properties that persist to ViewState. Declare a normal property and use an Attribute to tag it for storage to ViewState. See how to use reflection to see which properties need to be persisted.

New ASP.NET server control book for .NET 3.5 on 10 Jul 08 (Add comment)

Here’s a small plug for Joel who has just released a book on something quite dear to my heart, ASP.NET server controls. It’s called Advanced ASP.NET AJAX Server Controls for .NET Framework 3.5 and looks very interesting. I’m looking forward to adding it to my library. It’ll be nice to have an update to Nikhil’s […]

IButtonControl – any button will do on 30 Jun 08 (Add comment)

One nice feature of ASP.NET 2.0 is a new interface called IButtonControl. You can use it in a code behind to say a control needs to be a button but without actually saying whether it needs to be a Button, LinkButton, ImageButton or custom control button type. This is the type of thing that’s useful […]

UserControl template areas on 10 Jun 06 (1 comment)

ASP.NET smartie pants Scott Guthrie has linked to a really interesting article about supporting templated areas in ASP.NET controls. This is aimed at people doing user controls, but the same thing will work if you want to have a templated area in your own custom control. I’ve created a little sample that shows how to […]

Bookmark: ASP.NET DataBinding internals on 10 Apr 06 (Add comment)

I found a very interesting article about ASP.NET data binding that talks about exactly what’s happening when you call the DataBind() method on a templated control like the repeater. It’s got some really interesting stuff on how the templates are instantiated and how the child controls are built.

Pausing page rendering at a certain point on 07 Apr 06 (Add comment)

I don’t know if this will be useful to anyone else but I thought this was kind of a neat trick for messing around with ASP.NET page rendering for debugging purposes. My problem was I wanted to stop the rendering of a page at a certain point so I could see how the scripts were […]

UserControl type not available if code behind file isn't in app_code directory on 06 Apr 06 (2 comments)

I ran into a weird problem with dynamically created ASP.NET 2.0 user controls yesterday. I was using the user control to populate a panel of a tab control which meant I didn’t actually have a reference to the user control object anywhere on my form. The only way I could get a reference to it […]

WebResources aren't cached when debug is set to true in your web.config on 16 Mar 06 (Add comment)

On the subject of the ASP.NET 2.0 web resources, something very useful to know is they aren’t cached when debug is set to true in your web.config. My research suggests that regardless of this caching isn’t enabled at all on Cassini (aka the ASP.NET development server). It doesn’t seem to even cache static files and […]

Using the ASP.NET 2.0 Web Resource Attribute on 11 Jan 06 (11 comments)

ASP.NET 2.0 has a really nice feature that lets you compile site or component resources like javascript files into your assembly file instead of deploying these shared files to the wwwroot/aspnet_client directory like in ASP.NET 1.x. This makes your component/website much easier to deploy because it means you can keep everything you need in one […]

The resource cannot be found. on (4 comments)

I was playing around with embedded web resources and was having a problem loading some javascript files. When I cut and paste the script link from the source of my page into the browser’s address bar I got the following error message: The resource cannot be found. Description: HTTP 404. The resource you are looking […]

HOWTO: Create a web control that handles a postback on 24 Oct 05 (Add comment)

Step 1: Create a WebControl that implements the IPostBackEventHandler interface. In my example I’ve created a CustomButton control that is a HTML <span> element that acts like a real button by trigging a postback and firing a Click event. public class CustomButton : WebControl, IPostBackEventHandler { public CustomButton() { } public void RaisePostBackEvent(string eventArgument) { […]