Script control for ReportViewer causing conflicts How do I point report viewer to declared script control
I have a DNN website that declares a script control in the form Load of my report module.
If Not IsPostBack Then
Try
If DotNetNuke.Framework.AJAX.IsInstalled Then ' Check to see if the user has AJAX installed on their server
DotNetNuke.Framework.AJAX.RegisterScriptManager()
End If
Then in order to see the report in the viewer I am told to add the ScriptControl onto the page. However doing so causes a conflict in the page:
DotNetNuke.Services.Exceptions.ModuleLoadException: Unhandled Error Adding Module to ContentPane ---> System.InvalidOperationException: Only one instance of a ScriptManager can be added to the page. at System.Web.UI.ScriptManager.OnInit(EventArgs
e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) --- End of inner exception
stack trace ---
Now when I get the error I can see the report in the viewer but other objects that are relying on the declared script control do not work.
How do I inform the ReportViewer to use the script control that is declared in the page load?
March 21st, 2011 5:42pm
Hi DanRowe,
Thank you for your question.
I am trying to involve someone familiar with this topic to a further look at this issue. There might be some time delay. Appreciate your patience.
Thank you for your understanding and support.
Thanks,
Jerry
Free Windows Admin Tool Kit Click here and download it now
March 21st, 2011 11:13pm
Thanks for working on it and letting me know.
March 22nd, 2011 8:41am
Hi Dan,
It seems somehow you have multiple ScriptManager controls. The error message is telling us that we are trying to add a second ScriptManager. Please find out if there is a duplicate ScriptManager somewhere. The issue is not really in the Report Viewer.
ScriptManager Control Overview
http://msdn.microsoft.com/en-us/library/bb398863.aspx
Hope this helps.
Thanks!
Cathy Miller
Microsoft Online Community Support
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2011 11:37am
Hi Cathy
Yes there are 2 script managers on the page.
As noted in my original post there is a scriptmanager that is loaded on the page load.
If Not IsPostBack Then
Try
If DotNetNuke.Framework.AJAX.IsInstalled Then ' Check to see if the user has AJAX installed on their server
DotNetNuke.Framework.AJAX.RegisterScriptManager()
End If
This is required for interaction with the DNN framework and code on the page.
I have also placed from the toolbox a ScriptManager so I can see the output in the reportViewer. If I do not drag the new Scriptmanager onto the page the Report viewer Does not render the report. However when I do this then the DNN framework and related
code does not work because of the conflict.
So what I need to know is how I cna use the declared Scriptmanager for the reportviewer?
No settings are made to that Scriptmanager (the one from the toolbox)or the reportviewer control that point to each other so what is done behind the scenes that tells the reportviewer to use the scriptmanager? shouldnt I be able to tell the reportviewer
there is already one being used and to use that one?
thanks
March 30th, 2011 1:56pm
Hi Dan,
We actually do not need to declare a ScriptManager for the ReportViewer specifically. The page just needs a ScriptManager which ReportViewer will check for during the control load time. You can either register the control through the toolbox or through the
code (the way you are doing now on the page load). What probably we need to consider is:
1) Does the code (DotNetNuke.Framework.AJAX.RegisterScriptManager()) do what you think it should do (is it really registering the ScriptManager?)
2) When should you do the registration of the ScriptManager?
The ReportViewer control checks for existence of a ScriptManager while creating child controls (ASP.NET Page Life Cycle -
http://msdn.microsoft.com/en-us/library/ms178472.aspx) so if we are doing a programmatic ScriptManager registration, we will have to consider if we can register the ScriptManager before this
period.
Thanks,
Cathy Miller
Microsoft Online Community Support
Free Windows Admin Tool Kit Click here and download it now
April 4th, 2011 10:51am
Cathy
I am assuming that since initiating the Script manager in the page load does not work that I should then do it in the page init. This is the code that I placed in my page.init:
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
' This is set here before page objects are rendered because
' they might call a routine that will require the settings
TTSRoutines.PhysicalPath = Request.PhysicalPath
If Not Page.IsPostBack Then
If DotNetNuke.Framework.AJAX.IsInstalled Then ' Check to see if the user has AJAX installed on their server
DotNetNuke.Framework.AJAX.RegisterScriptManager()
End If
End If
End Sub
However this does not correct the Report viewer problem of not showing the report. It does avoid the conflict error between the duplicated controls as the second Scriptmanager is physically removed from the page, but the report viewer will then be blank.
To confirm this is not another problem related to the code and collecting the data I have added a gridview to the page and bound the data to it:
' ForTesting Need to add GridView in order to use this code
Dim MyView As New DataView
MyView = myDataSet.Tables(0).DefaultView
GridView1.DataSource = MyView
GridView1.DataBind()
This then shows the report data as expected. Additionally I am researching that the DNN code is in fact supposed to register the script manager control but I am also fairly certain that it does.
April 4th, 2011 11:54am
Bump
Hi This is still not resolved.
Please
Free Windows Admin Tool Kit Click here and download it now
April 7th, 2011 4:28pm
Hi Dan,
We are collaborating with various teams and will respond as soon as possible.
Thank you for your patience!
Cathy Miller
Microsoft Online Community Support
April 13th, 2011 10:47am
Thanks for the update.
Please let me know if you need anymore information. I have been researching this and have found nothing to clear this up.
Free Windows Admin Tool Kit Click here and download it now
April 13th, 2011 5:33pm
Bump
April 26th, 2011 3:35pm
Hi
Wondering how we are doing with collaboration regarding this problem??
Free Windows Admin Tool Kit Click here and download it now
May 10th, 2011 8:03am
Hi Dan,
I tested the following scenario:
1) I add the reportviewer control on a web form, to run a server report
2) I do not put the ScriptManager control on the Design View
3) Instead, I dynamically create the script manager on the PreInit, as follows:
protected override void OnPreInit(EventArgs e)
{
ScriptManager scripManager = ScriptManager.GetCurrent(this);
if (scripManager==null)
{
scripManager = new ScriptManager();
this.form1.Controls.Add(scripManager);
}
base.OnPreInit(e);
}
Note that, I did not call the "scriptManager.RegisterScriptControl" anywhere in my code behind.
Now when I run the sample form, it runs just fine. Knowing that scriptmanager registration check is done while creating child controls in the form, if we can put scriptmanager like this, the child control will be able to work with the scriptmanager, as per
my test.
I do not know what DotNetNuke.Framework.AJAX.RegisterScriptManager() actually does, but if it creates the scriptmanager as the example shows, this should work now.
Can you please test if this works, putting the DotNetNuke.Framework.AJAX.RegisterScriptManager() on the "OnPreInit"?
Hope this helps.
Thanks.
Meer Alam
Microsoft Online Community Support
May 10th, 2011 6:14pm
I will attempt this and let you know
Thanks
Free Windows Admin Tool Kit Click here and download it now
May 10th, 2011 6:45pm
I converted that to vb
If True Then
Dim scripManager As ScriptManager = ScriptManager.GetCurrent(Me)
If scripManager Is Nothing Then
scripManager = New ScriptManager()
Me.form1.Controls.Add(scripManager)
End If
MyBase.OnPreInit(e)
End If
now I do not find a pre init event there is a Page_prerender in the ASCX.vb is that what you are talking about?
I also have this code for the DNN script control in the load event. Do you want me to leave that there so they work together?
May 31st, 2011 4:38pm
I converted that to vb
If True Then
Dim scripManager As ScriptManager = ScriptManager.GetCurrent(Me)
If scripManager Is Nothing Then
scripManager = New ScriptManager()
Me.form1.Controls.Add(scripManager)
End If
MyBase.OnPreInit(e)
End If
now I do not find a pre init event there is a Page_prerender in the ASCX.vb is that what you are talking about?
I also have this code for the DNN script control in the load event. Do you want me to leave that there so they work together?
Also I get errors when I add the preinit sub to my code behind. it will not recompile saying event Precompile is not found
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2011 4:38pm
Hello Dan,
Looking at Page Life Cycle, the OnPreInit is the Page event handler. I am not sure about the DNN, as I do not know when the event handler, specific to DNNs will be invoked. For my test, putting the code on Page.OnPreInit, made it working.
Hope this helps.
Thanks.Meer Al - MSFT
June 6th, 2011 1:59pm
Asp.Net user controls do not have a PreInit event. Since your module control derives from PortalModuleBase which itself derives from UserControl, you cannot
override OnPreInit or handle a PreInit event in your module control. PreInit is one of the first (maybe THE first) events which is available to the Page and occurs before child controls are even instantiated as part of the Page's control collection.
Free Windows Admin Tool Kit Click here and download it now
June 7th, 2011 12:56pm