Print not working in ReportViewer - asp.net

Hi i am using Report service client definition (rdlc) for reporting in my asp.net web application.
I used a reportviwer for displaying report. But while clicking on the print button of report viwer the following error occures
Here is my aspx portion
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Visible ="false" Width="100%" Height="100%" ShowPrintButton="true">
</rsweb:ReportViewer>
</div>
If anybody knows please help me

The print button of SSRS report viewer is an ActiveX control.
This works only on IE. If you are using any other browser you will not be able to load this control. This ActiveX control is known to cause problems with IE 9 too.
So unless you stuck to a really old environment of IE7,IE8. Don't bother to use the print control that comes with reportviewer.
Provide a button to export the same report as PDF, and let your users print from there.

Where we've seen this problem, it's been because users haven't had permissions to install the ActiveX control into IE.
There's two suggested solutions here, one of which is to deploy the ActiveX control manually onto each machine where it's needed.

Related

Can't reference controls in code behind. Visual Studio 2012

There are quite a few questions out there regarding this (for me, recurring) issue, but none of them have solved my problem.
Problem:
Whatever control I add in my aspx page, it is not recognised in the codebehind. Compiling doesn't work, because the ID is not recognised.
None of the following worked:
Clean and rebuild solution.
Close and open VS
Delete asp.net temp files
Check project's target framework.
Check assemblies are all there.
Check designer viewn to see if the control is actually there (it is)
Get control's ID with JS function to check it is the intended one (it is)
The problem has started only recently. In fact, I can reference the older controls fine.
The problem is observed both with standard ASP controls and Telerik ones.
Does anyone know of something else I should try? Please help me, I'm in the middle of a project and this is causing unnecessary delays, ta.
Make sure all of your asp.net controls (in the .aspx file) have the:
runat='server'
tag... Without this, you will not be able to reference the controls.
e.g.
<asp:Label runat='server' Text='Test Label' ID='TestLabel' />
Hope this helped...
Rodit
This is how I solved my issue. For a full account of it, please refer to the comments above.
I've noticed that although my project was already of web application type, designer files weren't showing.
I've forced the designer files to be recompiled by clicking on the ''convert to web application' option
I was then able to reference the control ID.
Thanks to the commentators anyway.
I was having a similar issue, due to the fact that I was using the pre-generated Login page. My solution was to change this section from this:
<asp:Login runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
To this:
<asp:Login ID="asplogin" runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
basically, I just added an ID to the asp:Login which allowed me to access the objects in the code from behind by prefixing the control name with asplogin
asplogin.youControlNameHere

AJAX Control Toolkit Loading All Scripts

I have a bit of a weird problem I can't seem to fix. I am using the AJAX Control Toolkit's calendar extender on some of my pages. Despite the information I've found via the web I can't seem to get it working with a regular ScriptManager control, it only works with a ToolkitScriptManager. However I've noticed that when the page loads it adds some 84 script files for every possible control script provided by the toolkit:
Is this the expected behaviour, and can I turn it off? I only need it to load the relevant scripts to handle the calendar extender.
In current version of ACT you can group extenders in bundle and specify which bundles you need to include.
Add AjaxControlToolkit.config file to project like here Codeplex AjaxControlToolkit.config, add new controlBundle entry to this file for CalendarExtender like this:
<controlBundle name="Calendar">
<control name="CalendarExtender"></control>
</controlBundle>
and specify this bundle in ToolkitScriptmanager control:
<ajaxToolkit:ToolkitScriptManager runat="server" CombineScripts="true"
ScriptMode="Release" >
<ControlBundles>
<ajaxToolkit:ControlBundle Name="Calendar" />
</ControlBundles>
</ajaxToolkit:ToolkitScriptManager>
Use ControlBundles to solve this, follow this step about ControlBundles on how to do it.

asp.net page postbacks when mouse is moved over embedded youtube flash video

I am developing a site in which youtube video’s will be added to asp.net page using the HTML code given at youtube.com site. When I run the program, in the web page youtube video is displayed. But the strange thing is when I move mouse over the video display area the page postbacks happens. I am able to find this when I run the program in debug mode.
To exactly reproduce the scenario, I am writing the steps which I have done in my project.
1) In visula studio 2010 > Open asp.net web application project (with c# as language)
2) add some page, say cat.aspx
3) in cat.aspx write the code as below
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblVideo" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
4) in cat.aspx.cs, in page_load even write the following line
lblVideo.Text = "<iframe width=\"620\" height=\"349\" src=\"http://www.youtube.com/embed/WoTsE7pbuKg\" frameborder=\"0\" allowfullscreen></iframe>";
5)you can replace the above given by youtube.com, but be sure to set "http:" and escape " with \" as how I have done.(to get HTML code for any youtube video, visit www.youtube.com, click on any video or a famous song, below the video a menu "share" will be displayed, click on it, then another option "Embed" will be displayed, click on it, you will be presented with code)
6)Now run your web app project, you can see, youtube video is displayed.
7)Now run with break point set in Page_load event, now move mouse over the video display area, you can see for each time the mouse enters the video display area, a postback happens.
8) I have latest flash installed in firefox and InternetExplorer, this problem happens only in firefox and IE, not in chrome. And this problem happens only when we use Updatepanel. I also found that page does not postback (IsPostBack) is false when every time the control hits the codebehind. It is like page is requested for the first time as how we type the url in the address bar and press enter
I tried using asp:PostBackTrigger and asp:AsyncPostBackTrigger
Both are not giving solution to the problem, because what happens is not postback, it is fresh page request
Many Thanks in advance to anybody who try to help or give solution.

Script control is not a registered script control

I have a page that uses CustomerDetails.ascx. It uses CM.ascx. Inside CM.ascx I use AJAX Data Controls GridView with ID="gdvRecommendation".
Sometimes when I browse to the page I get the following exception:
Script control 'gdvRecommendation' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl
My ScriptManager defined in the master page before the content place holder.
This exception doesn't happened always.
I use CustomerDetails.ascx user controls in other pages and it works great.
Can anyone explain me the problem and what can be the solution?
Edit:
Here is the GridView usage in CM.ascx:
<td valign="top" style="height: 150px;">
<div id="divCMMessage"></div>
<div id='divRecommendation' style="width: 100%; display: inline; overflow: auto;">
<ADC:GridView ID="gdvRecommendation" Width="100%" runat="server" CellSpacing="0" CellPadding="3" HorizontalAlign="Right" ShowHeader="false" RowDataBoundEvent="onRowDataBound_gdvRecommendation">
<RowStyle Height="20px" />
<EmptyDataTemplate>no recommendations</EmptyDataTemplate>
<EmptyDataRowStyle HorizontalAlign="Right" BorderWidth="0" />
<Columns>
<ADC:GridViewImageColumn DataImageUrlField="IndImageUrl" HeaderText="" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center"></ADC:GridViewImageColumn>
<ADC:GridViewTemplateColumn HeaderText="">
<ItemTemplate>
<asp:Label ID="TreatName" runat="server" Text=""></asp:Label>
</ItemTemplate>
</ADC:GridViewTemplateColumn>
<ADC:GridViewTemplateColumn HeaderText="">
<ItemTemplate>
<asp:Label ID="TreatType" runat="server" Text=""></asp:Label>
</ItemTemplate>
</ADC:GridViewTemplateColumn>
</Columns>
</ADC:GridView>
</div>
</td>
The CustomerDetails.ascx is inside a MultiView (on MyPage.aspx).
I had a similar problem myself and this post helped me to understand my errors:
==============================================
Script control 'ControlName' is not a registered script control
So you're here because you got the following error.
Script control 'ControlName' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl
  
I myself have done a fair bit of googling on this, and there are many
solutions given all over the net. unfortunately these are all very
scenario specific solutions. Some people get their answers, and the
others, like me, don't.
Answer:
You are changing the visibility of a control at the wrong stage of the
page life cycle.
Description:
If you are changing the visibility of a control, you should always do
it during, or before the PreRender event. If you do it after (i.e. in
a End handler of an async task or during PreRenderComplete) you might
run in to this issue.
This is not an issue for simple controls such as buttons or text
boxes. But it will have adverse effects on controls such as grids.
When I say changing the visibility it could be any one of the
following situations
Having visible=false of a control during the early stages of the life cycle and being changed to visible=true during an end handler or PreRenderComplete
Changing the selected view of a MultiView during an end handler or PreRenderComplete
Any other situation where the control may not be visible during the earlier stages of the page life cycle which are set to be visible during the latter stage
 
Reason:
Purely
from my understanding, ASP.NET does not render the scripts or the HTML
related to a control if it is not being shown to the user. The
registering of script controls which is mentioned in the exception
seem to happen during an early stage of the life cycle. if the control
is not visible at this stage, this registration is skipped for that
control. If it's made to be visible at a latter point, you get
yourself a control without some of the relevant scripts.
Anyway this is what I have understood. I may be wrong. But if you come
across this issue, it will definitely help you to check for controls
which are changing visibility at different points of the life cycle.
You will be able to identify your specific problem by doing this and
then come up with a solution on your own.
Hope this information helps some one.
============================
Source
I faced same problem recently, above solution did not work for me. I was Hiding a control and later making it visible in PreRender based on some condition check. Hiding was working fine but when I was making it visible again, it was giving me the same error.
below is What worked for me is-
ScriptManager sm = ScriptManager.GetCurrent(Page);
sm.RegisterScriptControl(control_name);
Then making the control visible resolved my issue.
control_name.Visible = true;
Hopefully it may help someone facing this issue.
I had a similar issue with AJAX, and amusingly it occured only when in 'Debug' mode. In release mode, everything works fine. I have not reached to a conclusion on it yet.
You may want to give it a shot.
In case of a RadAjaxPanel and loading UserControls, reading the answer from jhfelectric, I came up with the following solution (simple one):
Disable AJAX on load (Me.EnableAJAX = False) and Enable it on PreRender. Because PreRender isnot called when removing a control, and is called after adding a control.
You can get this Exception when you have a RadAjaxManager in a user control that itself is also inside a RadAjaxManager, either directly or as the child of another user control.

What is the best way to include content within an AJAX TabContainer?

I didn't want to have a ton of code on one page, but to keep the code modular and simple. So in my TabContainer I have the following where each tab refers to a web page and my code is inside each web page. My TabContainer itself is inside the default.aspx page.
<asp:TabContainer ID="tabTOL" runat="server" ActiveTabIndex="0" CssClass="tol">
<asp:TabPanel ID="tabHome" runat="server" TabIndex="0" HeaderText="Home">
<ContentTemplate>
<iframe src="Home.aspx"></iframe>
</ContentTemplate>
</asp:TabPanel>
...
Of course, the problem is that I cannot refer to other tabs or the TabContainer/default page from within any tab. I'm trying to update a TextBox on the default.aspx page from a tab, but there is no reference to it.
Should I bite the bullet and have one huge web page with all the html and code behind? There are a dozen tabs in my TabContainer. I would think this would slow down processing as well. Or, is there a cleaner way to do this and still retain the ability to reference controls on the main page or other tabs?
I'm working in VS2008 and .Net 3.5 and AJAX 3.5.
Thanks!!
Larry
I would suggest that you change the structure of Home.Aspx into a Web User Control (*.ascx). The advantage is that you are now running within the context of the parent page. Therefore all it's functionality is within reach. For example, to acces a textbox on the parent page, from the Home.Ascx, you would do this:
((Default)this.Parent).txtMyTextBox.Text = "Hello";

Resources