colinramsay.co.uk

ASP.NET Postback Problems in Controls

20 Apr 2004

There are some people hitting this site when searching for ASP.NET postback - here's another solution I found.

A User Control is ASP.NET consists of a .ascx file and an optional .cs file. If you try and dynamically create something like a DataGrid in a User Control, you'll be screwed - your DataGrid buttons won't work. I've not yet found the exact reason for this, but I did find a workaround.

Use a Custom Control. A custom control is a control which you create in a .cs file and then compile into a .dll. You can then reference this in your pages as you would a user control. The disadvantage is that you have no .ascx file - you don't have that templating which they provide... unless you include a Custom Control within a User Control :o

Feedback or questions on this post? Create an issue on GitHub.