Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

Last post 07-31-2006 9:49 PM by lodestar. 7 replies.

Sort Posts:

  • Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-25-2006, 10:40 AM
    • Member
      30 point Member
    • lodestar
    • Member since 07-25-2006, 10:16 AM
    • Posts 6
    I'm using the June 06 CTP. The following code illustrates this problem: I created a composite control that contains a dropdown listbox. I added a <atlas:scriptmanager> tag to my page and set the property "EnablePartialRendering=True". When selecting an item in that dropdown listbox (which has AutoPostback=True), the page never posts back. I've verified that all page events through PreRender fire in the composite control, however the Render event never fires. If I set EnablePartialRendering="false", the page postsback successfully and Render fires.

    The following code represents my (much stripped down) composite control:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace MyWebControls
    {
    public class DropInputField : CompositeControl
    {
    protected DropDownList _fieldList;

    public bool AutoPostBack
    {
    get { EnsureChildControls(); return _fieldList.AutoPostBack;
    }
    set { EnsureChildControls(); _fieldList.AutoPostBack = value;
    }
    }

    public object DataSource
    {
    get { EnsureChildControls(); return _fieldList.DataSource;
    }
    set { EnsureChildControls(); _fieldList.DataSource = value;
    }
    }

    protected override void OnLoad(EventArgs e)
    {
    if (!Page.IsPostBack || !EnableViewState)
    {
    DataBind();
    }

    base.OnLoad(e);
    }

    protected override void CreateChildControls()
    {
    Controls.Clear();
    CreateControlHierarchy();
    }

    protected virtual void CreateControlHierarchy()
    {
    _fieldList = new DropDownList();

    Controls.Add(_fieldList);
    }

    protected override void Render(HtmlTextWriter writer)
    {
    _fieldList.AutoPostBack = AutoPostBack;
    _fieldList.RenderControl(writer);
    }

    public override void DataBind()
    {
    EnsureChildControls();
    _fieldList.DataBind();
    }
    }
    }
     The following code represents the page which uses this control:
    <%@ Page Language="c#" %>
    <%@ Register TagPrefix="MyWebControls" Namespace="MyWebControls" Assembly="MyWebControls" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server"></head>
    <script runat="server">

    protected void Page_Load(object sender, System.EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    ArrayList a = new ArrayList();
    a.Add("a");
    a.Add("b");
    a.Add("c");
    country.DataSource = a;
    country.DataBind();
    }
    }
    </script>
    <body>
    <form id="form1" runat="server">
    <atlas:ScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true" />
    <MyWebControls:DropInputField ID="country" runat="server" AutoPostBack="True" />
    </form>
    </body>
    </html>


    In firefox, the following error appears in the javascript console:
    Error: not well-formed
    Source Code:
    <delta><pageError message="Object reference not set to an instance of an object." /></delta></delta>---------------------------------------------------------------------------------------------^

    In IE, I don't get any errors

  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-25-2006, 3:01 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    you're getting a server side error. handle the page error event (fired by scriptmanager control) and see what you're getting there. the stack should tell you wah'ts going on.

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-25-2006, 3:23 PM
    • Member
      30 point Member
    • lodestar
    • Member since 07-25-2006, 10:16 AM
    • Posts 6
    Luis:

    Here are the error details:

    ErrorMessage = "Object reference not set to an instance of an object."
    Source = "Microsoft.Web.Atlas"
    Stack trace= at Microsoft.Web.UI.ScriptManager.RenderFormCallback(HtmlTextWriter writer, Control containerControl
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
    at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
    at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
    at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
    at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
    at Microsoft.Web.UI.ScriptManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)

    There's not much I can do with that, as the exception is occurring in Microsoft.Web.Atlas.dll. Wink
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-26-2006, 3:51 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello again.

    ah, but i can, but i can :)

    the problem you're facing is a bug introduced by the scriptmanager control on the renderformcallback. it happens because you don't have updatepanels on your page (yep, it's a bug all right!). if i'm not mistaken, you'll find my description on the second page of the next thread

    http://forums.asp.net/2/1332304/ShowThread.aspx

    a quick workaround is to add a dummy hidden updatepanel. btw, i think i didn't add this to garbin's list...i'll do that right now.

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-26-2006, 10:59 AM
    • Member
      30 point Member
    • lodestar
    • Member since 07-25-2006, 10:16 AM
    • Posts 6
    OK, putting an update panel on the page took care of the exception. However, there are still another  bug here.

    I beefed up my original sample code (below) by adding an <asp:DropDownList> to provide a comparison between its operation and the operation of my composite control, which is really nothing more than a wrapper around an <asp:DropDownList> (of course, it started it's life out as something much more but I've stripped it way down to demonstrate the issue).

    Here's what I'm observing:
    1) first time page loads: when you change the selected item in the <asp:DropDownList>, you 'see' the page postback (page flickers/status bar's progress bar appears). Any new selection you make in this dropdown postsback the page as expected, and the SelectedIndexChanged event fires.
    2) Now select an item in the dropdown list from the composite control. You don't 'see' the page postback, although I've verified all page events through render fire successfully. Selecting an item in this list should mimic the <asp:DropDownList> behavior, but doesn't.

    Also, you get a javascript error 'dataPanelRendering has no properties'. Error occurs on line #11300 of  Atlas.js:
    deltaPanelRendering = Sys.UI._unescapeCData(deltaPanelRendering.firstChild.nodeValue);

    3) Now select a different item in the <asp:Dropdown> list. You no longer see the page posting back, nor do any page events or the SelectedIndexChanged event fire on this dropdown list.

    Both lists are broken for good until you refresh.

    Here's the page source you can use to reproduce this (and use the composite control source from my first post):

    <%@ Page Language="c#" %>
    <%@ Register TagPrefix="MyWebControls" Namespace="MyWebControls" Assembly="MyWebControls" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>

    <script runat="server">
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ArrayList a = new ArrayList();
                a.Add("a");
                a.Add("b");
                a.Add("c");
                country.DataSource = a;
                country.DataBind();

                drpTest.DataSource = a;
                drpTest.DataBind();
            }
        }
    </script>

    <body>
        <form id="form2" runat="server">
            <atlas:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="true">
            </atlas:ScriptManager>
            <div style="width: 550px">
                <MyWebControls:DropInputField ID="DropInputField1" runat="server" AutoPostBack="True" />
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" />
            </div>
            <atlas:UpdatePanel ID="UpdatePanel1" runat="server" Visible="false">
                <ContentTemplate>
                </ContentTemplate>
            </atlas:UpdatePanel>
        </form>
    </body>
    </html>
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-31-2006, 2:46 PM
    • Member
      135 point Member
    • noahwsmith
    • Member since 06-01-2006, 3:42 PM
    • Posts 27
    This is also a known bug in the June CTP: http://forums.asp.net/thread/1335914.aspx (with the broken til refresh thing).
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-31-2006, 9:18 PM
    • Member
      30 point Member
    • lodestar
    • Member since 07-25-2006, 10:16 AM
    • Posts 6
    I don't think the issue I'm reporting is the same as the one in the post you referenced.

    The post you referenced refers only to async calls breaking controls until a page refresh. The issue I'm reporting has nothing to do with asynch calls. I'm using dropdown lists to postback (via AutoPostback=True) to the same page and the postbacks no longer work after the 1st postback.
  • Re: Bug: scriptmanager with EnablePartialRendering="true" breaks composite control with dropdownlistbox

    07-31-2006, 9:49 PM
    • Member
      30 point Member
    • lodestar
    • Member since 07-25-2006, 10:16 AM
    • Posts 6
    Verified that this is still broken in the July CTP (Microsoft.Atlas.dll v2.0.50727.60725)
Page 1 of 1 (8 items)