Bug in Asp.Net 2.0 WebControlAdapter RRS feed

  • Question

  • User-538256727 posted

    There is bug in the WebControlAdapter class that can be very annoying, so I thought I'd fill eveybody in on the details.

    The WebControlAdapter by default calls base.Render in it's render method. On most occasions, this is no problem. However, for TextBox it is. Try adding a multiline textbox and adding a TextBox control adapter using the WebControlAdapter base class: the multine textbox refuses to maintain it's state. All was working well for regular textboxes, so had a look at the .net internals to figure out what's going on. It turns out that the textbox rendering method has a conditional statement for rendering multiline textbox controls which get's ignored when using the WebControlAdapter. So when writing an adapter for the textbox control, you always have to implement to render method, like so:

                if (Extender.AdapterEnabled)
                    //base.Render(writer); // this causes a bug where multiline textboxes can't maintain state
                    if (textbox.TextMode == TextBoxMode.MultiLine)
                        System.Web.HttpUtility.HtmlEncode(textbox.Text, writer);

    Thursday, December 27, 2007 11:14 AM

All replies

  • User1084001315 posted
    Excellent information, exactly what I was having trouble with, thanks for the post!
    Thursday, October 23, 2008 1:03 PM
  • User-1790781538 posted

    Thanks, Rinze! What a weird issue.

    Friday, January 7, 2011 3:13 PM