Using DropDownList with an UpdatePanel in MOSS 2007

Just a quick note (mostly for myself, but sharing is caring :) )..

once MOSS SP1 has been installed and you want to implement an UpdatePanel in a web part on MOSS 2007 in order to capture a SelectedIndexChanged event from a DropDownList you have to add the following to your page_load event

 if (this.Page.Form != null)
            {
                if (this.Page.Form.Attributes["onsubmit"] == "return _spFormOnSubmitWrapper();")
                    this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                 "UpdatePanelFixup",
                                                 "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;",
                                                 true);

Otherwise the event wont be captured by the scriptmanager...

 

Published Fri, Feb 8 2008 8:21 by Brian Madsen
Filed under: