I have an Infragistics grid working fine in a User Control ASCX file. Now I am trying to load it into a web part. Initially an error said "you need a script manager on the page". So I added it during CreateChildControls:
this.Controls.Clear() this.Controls.Add(new ScriptManager()); userControl = (UserControl)this.Page.LoadControl (@"/_controltemplates/myUserControl/myListControl.ascx"); this.Controls.Add(userControl);
Now I get the following error, which you may get if your OnPreRender methods do not call base.OnPreRrender. I checked using reflector, and the Infragistics methods FlatDataBoundControl and WebDataGrid do indeed call base.OnPreRender. These are the only PreRender events in the stack. Note: I do not override OnPreRender myself.
Any ideas? Thanks! Ed.
[InvalidOperationException: Script controls may not be registered before PreRender.] System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +349529 System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +66 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.OnPreRender(EventArgs e) +1111 Infragistics.Web.UI.GridControls.WebDataGrid.OnPreRender(EventArgs e) +5 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() +42 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
Hi,
I ran into the same problem and trying to solve his in differernt ways, overriding PreRender, setting a ScriptManager in OnInit but nothing worked.
The solution is to look at the AjaxSmartPart.cs from http://smartpart.codeplex.com/SourceControl/ListDownloadableCommits.aspx. I included the code from the OnInit method in the AjaxSmartPart.cs into the OnInit in the webpart that loads the user control. Now the ScriptManager is loaded correctly in our environment.
Reagrds