|
 |
 Tuesday, February 08, 2005
Differences between System.Web.UI.LiteralControl and System.Web.UI.WebControls.Literal
Mike Ogden pointed out the fact that the DynamicControlsPlaceholder (DCP) does not correctly recreate System.Web.UI.LiteralControl. At first I was very perplexed because I was somehow sure that I successfully tried that before. However, I must have mixed it up with the System.Web.UI.WebControls.Literal which works without problems.
That raises the question why there are two different controls and how they differ. The major difference is that the LiteralControl does not persist the Text property in ViewState, which is why it is recreated emptily by the DCP. The Literal, however, takes a LiteralControl as a child and saves its Text in ViewState:
protected override void AddParsedSubObject(object obj)
{
if (!(obj is LiteralControl))
{
throw new HttpException(
HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type",
"Literal", obj.GetType().Name.ToString()));
}
this.Text = ((LiteralControl) obj).Text;
}
So, if you want to use literal controls with the DynamicControlsPlaceholder make sure that you use Literal instead of LiteralControl. ASP.NET | DynamicCtrlPlh
2/8/2005 8:40:45 PM (W. Europe Standard Time, UTC+01:00)
|
|
 Wednesday, January 12, 2005
 Wednesday, October 06, 2004
 Thursday, June 24, 2004
 Tuesday, March 30, 2004
Article on ASPAlliance about LoadControl vs LoadTemplate
While developing the HierarGrid I noticed that there are some subtle differences between loading UserControls with Page.LoadControl and Page.LoadTemplate. Without digging deeper into that I decided to add a property “TemplateControlMode” to the HierarGrid so that the developer can choose which way to load the template.
After some users asked what the "right" setting for the property is or reported exceptions that were related to choosing the "wrong" setting, I decided to take a look at the two implementations to find the differences. My new article on ASPAlliance explains what I've found. ASP.NET | HierarGrid
3/30/2004 2:55:27 PM (W. Europe Standard Time, UTC+01:00)
|
|
 Monday, February 02, 2004
"Behind the scenes of ASPX files"
A nice article called Behind the scenes of ASPX files by Natty Gur describes how dynamic compilation in ASP.NET works and extends the last paragraph of Dino's article The ASP.NET HTTP Runtime I wrote about a couple of months ago.
Still, I am missing an article that explains how dynamic code generation in ASP.NET works from an ASPX page with a couple of markup tags through the PageParser into a .cs file that is then compiled into a .NET assembly. ASP.NET
2/2/2004 12:42:20 AM (W. Europe Standard Time, UTC+01:00)
|
|
 Monday, December 08, 2003
 Saturday, September 27, 2003
nGallery v1.0 Released!
That sounds pretty cool though I haven't tried it out (from Jason Alexander):
nGallery v1.0 Released!
Visit the nGallery site at http://www.ngallery.org to download!
nGallery is a FREEWARE, OPEN SOURCE implementation of a image gallery written purely in managed .NET and C#.
nGallery provides a solution to store and display your image galleries on your own Web site, as well as providing means for customizing and extending nGallery to your own personal likings. ASP.NET
9/27/2003 3:03:07 PM (W. Europe Standard Time, UTC+01:00)
|
|
 Wednesday, September 24, 2003
Why the CheckBoxList always has one child control
Today Ben Feist emailed me pointing out a problem with the DynamicControlsPlaceholder (DCP) and the CheckBoxList (CBL). He always receives a "Multiple controls with the same ID" exception when putting a CBL onto the placeholder.
So I took a look at the implementation of the CheckBoxList and noticed that like the DropDownList and the RadioButtonList (RBL) it is derived from ListControl which contains a ListItemCollection. This collection implements IStateManager and is saved in ViewState. So no need for the DCP to save the single ListItems. Why does it work with the RBL but not with the CBL?
Examining the RBL I noticed that when it comes to the render phase for each ListItem a RadioButton instance is created and written to the output TextWriter directly (see RBL.RenderItem for reference). So the ListItems/RadioButtons are never contained in the Controls collection which is used by the DCP. No problem for the DCP!
However the CBL works a bit differently: In the constructor a CheckBox control is created, added to the child collection (!) and stored in the internal member controlToRepeat. In the render phase for each ListItem the controlToRepeat is modified to reflect the text and checked state and then written to the output stream.
That's the problem for the DCP. At the end of the first request, it loops over the Controls collection noticing the CheckBox and persisting it. After the postback, the CBL constructor creates a new CheckBox again and then the DCP recreation algorithm restores the "same" CheckBox (ID="0" is hardcoded). This causes the duplicate control ID exception.
I wondered why the CBL constructor creates this special CheckBox and to find out I created a MyCheckBoxList with a "this.Controls.Clear()" constructor ;) That solved the duplicate ID problem.
However, Ben pointed out that the MyCheckBoxList does not pick up the SelectedIndex and a quick look at LoadPostData and the HTML source revealed that the NamingContainer was incorrect.
To make a long story short, the CheckBox is added to the child collection so that the NamingContainer of the parent CBL is automatically prefixed to the ListItem index ("[CBLID]_0"). The RBL achieves the same thing manually in the RenderItem method (button1.ID = string.Concat(this.ClientID, "_", repeatIndex.ToString());)
Elegant but not very intuitive - I would expect to find either all ListItems in the control collection or none at all. So, if you ever wondered why the CBL always has exactly one child control no matter how many ListItems there are in your Items collection, you know now. ASP.NET
9/24/2003 6:07:43 PM (W. Europe Standard Time, UTC+01:00)
|
|
 Monday, September 22, 2003
Article: Creating Custom Columns for the ASP.NET Datagrid
In case you haven't already noticed Marcie's article on custom DataGridColumns. It's worth taking a look at not only if you want to understand how the HierarGrid works. There, I created the so-called HierarColumn that acts as the container for the child templates and is filled during the ItemDataBound event.
Good job, Marcie! ASP.NET
9/22/2003 3:09:53 PM (W. Europe Standard Time, UTC+01:00)
|
|
 Wednesday, September 10, 2003
Two excellent ASP.NET articles
For the last couple of weeks I had two MSDN article links on my desktop to read as soon as time permits. When I had two office days last week I read both of them and think that they are really excellent.
The first article by Dino Esposito is called The ASP.NET HTTP Runtime and covers the complete flow a request takes:
- coming into IIS
- handing over to the ASPNET_ISAPI extension
- passing it through named pipe to the worker process where managed code processing is taking place
- picking up a HttpApplication instance from the HttpApplicationFactory pool
- calling into ProcessRequest/ProcessRequestMain
The last chapter covers some basic aspects about dynamic compilation and the file structure in the "Temporary ASP.NET Files" folder.
I used the article as a guided Reflector tour through the down-level classes of the System.Web namespace by reading a bit and then checking what I've read in the source code (and vice versa).
The second article called Use Threads and Build Asynchronous Handlers in Your Server-Side Web Code by Fritz Onion is not directly related with the first one but picks up some learnings from it. Basically, Fritz describes the typical problem that the main executing thread is waiting for an external resource causing it to be blocked thus resulting in bad scalability. He develops an async HttpHandler that starts a separate thread which does not belong to the ASP.NET thread pool. Pretty cool is the base class he provides that can be used as a replacement for System.Web.UI.Page for individual ASPX pages.
Both articles are very much worth reading.
I am still missing one aspect of ASP.NET written down in an article: dynamic code generation from ASPX markup language to C#/VB code (PageParser etc.). Does anyone know a good article covering this topic?
ASP.NET
9/10/2003 12:15:23 AM (W. Europe Standard Time, UTC+01:00)
|
|
|
|
Blogroll
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 28 | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 10 | 11 | 12 | 13 | | 14 | 15 | 16 | 17 | 18 | 19 | 20 | | 21 | 22 | 23 | 24 | 25 | 26 | 27 | | 28 | 29 | 30 | 31 | 1 | 2 | 3 | | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| |
|
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in anyway.
© Copyright 2010, Denis Bauer
|