reportviewer date parameter and calendar.. not working and javascript errors??
Hi, I've got this ssrs 2005 report that works great passing a few security related parameters from asp.net codebehind. However, there are two date related parameters that won't be coming from my web form, but rather from the report form itself. When I test the report's date parameters from visual studio it work fine, but when I attempt the same report from a reportviewer no matter what input I place on the report's date fields or even if I select the date picker, the report simply resets to default and reloads. And actually the date picker from the reportviewer does not not even pop up. Here's my aspx code: <%@ Page Language="VB" AutoEventWireup="false" Inherits="_ReportViewer" MasterPageFile="~/Main/MasterPage.master" CodeFile="~/Reports/CashSales.aspx.vb" Title="Cash Sales" %> <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> <asp:Content ID="Content1" ContentPlaceHolderID="Content1" runat="Server"> <rsweb:ReportViewer BackColor="Transparent" ZoomMode="PageWidth" Width="100%" ProcessingMode="Remote" ID="ReportViewer1" runat="server"> <ServerReport ReportPath="/Retailer/CashSales" ReportServerUrl="http://myserver/reportserver" /> </rsweb:ReportViewer> </asp:Content> Note: I'm only passing the parameters that are not coming from the reportviewer form. the code behind: Imports system.web.security.membership Imports system.web.security.Roles Imports Microsoft.Reporting.Webforms Partial Class _ReportViewer Inherits System.Web.UI.Page Private Users As New Retailer.Core() Protected Overrides Sub OnLoad(ByVal e As EventArgs) Dim Roles() As String = GetRolesForUser(Page.User.Identity.Name.ToString) Dim cred As New Retailer.ReportServerCredentials("myuser", "mypassword", "mydomain") ReportViewer1.ServerReport.ReportServerCredentials = cred Dim param As New ReportParameter("r_user", Page.User.Identity.Name.ToString) Dim param2 As New ReportParameter("r_role", Roles(0)) Dim p() As ReportParameter = {param, param2} ReportViewer1.ServerReport.SetParameters(p) ReportViewer1.ServerReport.Refresh() End Sub End Class on my reportviewer form, at the top I have parameters for startdate and end date, they are not set to internal or hidden. If I select the calendar icon, i get a javascript error Line: 606 Object Required When I attempt to debug I get a Just-In-time failed : Unspecified error. Check the documentation index for 'Just-in-time debugging, errors' for more information. So pretty much I can't see the error or javascript in question. If i enter anything in the date fields, it disregards them setting them to the defaults. Again, if i run the report from my vs.net client (not using reportviewer), i can select the calendar and enter dates and it respects them. Any chance I need to patch sql server or reporting services? maybe ie. I'm on IE7.0.5730.11 Could my problem be that selecting items on the report itself fails to send my credential information from my codebehind? Thanks for any help or information!
October 23rd, 2007 1:03am

I am having the exact same problem when i integrated the reports with my ASP.NET 2.0 Application using master and content page. I am also facing this problem with the Multi value select drop down in report viewer control. I also figured that it worked fine if i didn't use the master/content page, instead just putting a report viewer control on a stand alone page. It would really be a help if somebody knows the remedy to this problem of calendar and multi value dropdown.
Free Windows Admin Tool Kit Click here and download it now
October 25th, 2007 1:40am

hello. I reached the same conclusion with master/content page. Also looking for a solution here.
October 25th, 2007 2:52pm

Having the exact same problem! Anybody found a solution yet? Thanks!!
Free Windows Admin Tool Kit Click here and download it now
October 29th, 2007 11:05pm

Try putting your code in a "If Not IsPostBack" block. My code only sets the ReportServer and ReportPath settings and I had a similar problem. Putting those two lines in the if statement fixed it.
November 6th, 2007 5:00pm

My code is already in "If not postback" block, i figured that out when i was facing the problem in navigating using click through reports, the click through problem was fixed with that but not the calender and multivalued parameter dropdown. I still think it is because of the master/content page model.
Free Windows Admin Tool Kit Click here and download it now
November 6th, 2007 10:02pm

Okay Guys I ran into the same problem recently in a system i'm working on. The problem exists in the code that RS uses to position the date picker control. Suffice to say, i'm not sure why it isn't working but in one of the calls to the function, below, function GetObjectPosition(obj) { var totalTop = 0; var totalLeft = 0; while (obj != document.body) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; return {Left:totalLeft, Top:totalTop}; } the obj parameter is null, which causes the offsetTop/offsetLeft properties to throw the error mentioned. Right, now for the fix... Because I didn't want to dig into the base code for the control, and i'm fairly good at js, I wrote a replacement control for the datepicker (well actually I had one in my library) that identified the calendar controls on-load and removed the broken code from their onclick events. I then intantiated my own datepicker control, and added some bindings to make it display when the imgae was clicked or the input was focused. The code below, requires the Eulerian Technologies Datepicker object, a few personal modifications to it, though it won't break if you dont have them, and the fantastic prototype.js library that you can get from http://www.prototypejs.org. In a javascript block, <script></script> below your ReportViewer control, place the following code: <script language="javascript" type="text/javascript"> //Watch onload Event.observe(window,'load',function(e){ //Get image inputs var imageInputs = $$('input[type=image]') //filter the list and bind var calendarsButtons = imageInputs.findAll( function(item){ //check this item //get src var src = item.readAttribute('src'); //does this item's src make it a calendar return (src.endsWith('calendar.gif') || src.endsWith('calendar_disabled.gif')); }).each(function(item){ //process the filtered list //clear the standard onclick event item.onclick=null; //work to the left of the image control (calendar icon) and find the input var input = item.previous('input[type=text]'); //intialize the datepicker and store a reference to it against the input box input.dp = new DatePicker({relative: input.identify(), language:'en', keepFieldEmpty:true, relativePosition:false, enableCloseOnBlur:true }); //calculate the cumulativeOffset for the datepicker control (this is basically what the original code is trying to do) var p = input.cumulativeOffset(); //Set the datepicker position input.dp.setPosition( p[1], p[0] ); //Put a new click event on the calendar icon Event.observe(item, 'click', function(e){ //Find the input again var input = item.previous('input[type=text]'); //Click it input.click(); //Stop the event to prevent postback Event.stop(e); }); }); }); </script> If you don't want to include prototype, or replace the datepicker control, you can do the following. Since all top level functions are objects in the window namespace, the failing function can befound by referencing window.functionname, in this case window.GetObjectPosition. You can do the following: <script language="javascript" type="text/javascript"> window.GetObjectPosition = function(obj){ return { Left:0, Top:0 }; }; </script> This will mean that when the method is called internally, it will return 0,0 as the position for the datepicker and all will be well. Realistically, this isn't much use- you should replace the method with a function that calculates the cumulativeOffset of the control correctly, but since prototype implements this for me, i've not provided a method for you guys. Good luck, have fun. Hope this helps someone else trawling the web for the problem. Incidentally, a service pack for reporting services might fix this, but I didnt investigate it. The datepicker looks much nicer when it's styled the same as the other datepickers in the application. Gareth Evans Sniper Systems Limited http://www.snipersystems.co.nz
January 18th, 2008 4:32am

Does anyone have more information about this? I am having the same troubles and am hoping there is a hotfix out there that addresses this problem. Thanks -JW
Free Windows Admin Tool Kit Click here and download it now
June 12th, 2008 12:50am

Thanks for your fix! Its a year since your wrote this, but Microsoft still hasn't fixed this bug. It was very hard to find your fix on the Internet. It took quite of bit of searching! Do you know how to fix the multivalue report parameter bugs? They don't work very well on the Internet for people writing their own ASP.NET Web site as a front end using ReportViewer control and passing in parameters. (Whether or not Dates are being passed in from the calling Web App or not). Thanks!
October 7th, 2008 9:31pm

Hi John I've not encountered a scenario where i'd have to fix the multivalue report parameter, as although I use the report viewer control, I haven't tried passing parameters into the report. I suspect that a similar technique could be implemented to solve the problem - 1) Create some hidden inputs somewhere on your page that contains the values for the multiselects. 2) Find something unique to a multivalue picker, and use dom manipulation to work your way down to the checkboxes 3) Perform a lookup in your hidden field and update the checkbox states. You may run into cross frame scripting issues, but I can't remember the specifics of this. (e.g. child cannot read/change certain values in parent and vice versa) As i've not fixed this problem directly, I don't have any sample code for you, but if you need help with the prototype code (to locate the objects and perform dom manipulation etc), the prototype-scriptaculous google group is a great place to start. Best of luck, Gareth
Free Windows Admin Tool Kit Click here and download it now
October 8th, 2008 12:23am

Your fix of: <script language="javascript" type="text/javascript"> window.GetObjectPosition = function(obj){ return { Left:0, Top:0 }; }; </script> Also fixes the problem with the MutliValue Report Parameters, not just the Datetime Calendar. I don't know much about JavaScript, but I discovered the real problem is that the While loop in the orginal Microsoft .js code is not testing for Null when it is traversing the object heirarchy. I am going to install FireFox and a JavaScript debugger to try to write the fix to the original code that will allow it to correctly calculate the left and top offsets and repost it. When I get to it... hopefully tomorrow. Your find was important, because I had really needed to use the Multi-Value Report Parameters with a SQL Datasource query, and I thought it wasn't working from the web, but when I discovered that the MultiValue parameters wasn't working for hardcoded list of values either, I retested it withyour fix and it worked. Originally I had thought that having a SQL DataSource being populated by a hidden Report Parameter was the problem, when the real problem was with the GetObjectPosition function all along. Note: I am NOT passing in a Multi-Value Report Parameter or passing in DateTime field parameter, I am passing in a hidden integer parameter, but the Datetime parameter and the Multi-Value Parameters are on my reports for the users to select at report runtime. I am really surprised that Microsoft hasn't published the fix to this javascript yet.
October 8th, 2008 11:31pm

Try this John, I got it from prototype.js window.GetObjectPosition = function(element){ var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; if (element) { if (element.tagName == 'BODY') break; var p = Element.getStyle(element, 'position'); if (p == 'relative' || p == 'absolute') break; } } while (element); return { Left:valueL, Top:valueT }; }
Free Windows Admin Tool Kit Click here and download it now
October 9th, 2008 12:40am

I tried this and its doesn't seem to be working. Will this stop when it gets to the when it gets to an Element that is Null? I am going to work on the problem now. Thanks.
October 9th, 2008 5:45pm

In ReportingServices.js on your ReportingServices Server: C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\js it has the code: function GetObjectPosition(obj) joh { var totalTop = 0; var totalLeft = 0; while (obj != document.body) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; return {Left:totalLeft, Top:totalTop}; } It appears that Microsoft has a bug in their DOM, because JavaScript is blowing up on obj = obj.offsetParent --> obj ends up having a "6" in it when I was looking at in a JavaScript debugger. The very next statement causes a blow up. I also added "if (typeof obj.offsetParent = "Object")" which evaluated as true, but if you try to use Obj after this, it only blows up. Its a weird problem, because if you look at obj.offsetParent in the JavaScript debugger, it shows up as there and you can see all of its data. I thought I read somewhere that this problem can be caused by using an aspx that is the child of a Master Page. Maybe. I also put a Try / Catch block arround "obj = obj.offsetParent" which helped only temporarily. In the end, we need to traverse the parent containers to get the real offset in order to position the calander or the multi-value drop down correctly. I also tried: var totalTop2 totalTop2 = obj.offsetParent.offsetTop Which put "void" into totalTop2. It appears there is no way too use the obj.offsetParent in JavaScript, even though the Debugger is showing it. The best I have been able to come up with is: <script language="javascript" type="text/javascript"> window.GetObjectPosition = function(obj) { var totalTop = 75; var totalLeft = 0; return {Left:totalLeft, Top:totalTop}; } </script> This works good only if the report parameter area is up to two lines in height.
Free Windows Admin Tool Kit Click here and download it now
October 10th, 2008 4:27pm

Thanks John. Your several lines of JavaScript works for me - I use a ReportViewer control in a asp.net content page. For pages which does not use any master page, this may be a solution: http://social.msdn.microsoft.com/Forums/en-US/vsreportcontrols/thread/7aa6ede3-1ddc-49fc-abaa-d1ef270ad473/
October 14th, 2008 11:12am

I ended up using this JavaScript, because it is a modified version of the Original Microsoft code that doesn't blow up: <script language="javascript" type="text/javascript"> window.GetObjectPosition = function(obj) { var totalTop = 0; var totalLeft = 0; if (obj != null) { while (obj != document.body) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration try { obj = null; obj = obj.offsetParent; } catch (e) { //We can't calculate things right because it's hosed, so fix it. totalTop = 75; //Most important fix. break; } if (obj = null) break; } } if (obj != null) { totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; }; return {Left:totalLeft, Top:totalTop}; } </script>
Free Windows Admin Tool Kit Click here and download it now
October 16th, 2008 9:52pm

Thanks for this fix - the reports work in my .Net solution now.I was wondering if there is a way to make the calendar selection pop up box be in line with the icon to select it ... at the moment when I select the calendar icon, the calendar pop up box always appears on the left hand side of the page regarless of the icon position.
February 2nd, 2009 1:57am

Hi, I got solution see that aTag =ctl while(aTag!= document.body) { if (aTag!=null) aTag = aTag.offsetParent; if(aTag == null) { leftpos =95 toppos = 75 break; } else { leftpos += aTag.offsetLeft; toppos += aTag.offsetTop; break; } } From MuraliS.E
Free Windows Admin Tool Kit Click here and download it now
February 27th, 2009 2:54pm

Clearly building solutions that depend on modifying .JS files in the Report Viewer, or tying code to a control ID are workarounds and are inherently fragile. I've sent mail to the owner of the ReportViewer control to make him aware of this issue. I would request that if others are encountering this issue, still, that you open a bug on http://connect.microsoft.comand post the connect ID number so that others can vote for this issue. Sorry about the problems you've encountered.-LukaszThis posting is provided "AS IS" with no warranties, and confers no rights.
April 3rd, 2009 6:31pm

I'm having the same issue with GetObjectPosition(obj) failing due to obj suddenly becoming null on the call.I'm using VS2005 and .Net 2.0 and have a ReportViewer in the content area of a MasterPage. The Report I'm running requires a dropdown list and i have a parameter defined to do jsut that. But when you select the button to open the dropdown I get a null reference error in the GetObjectPosition in the ReportViewer js. Specifically this function: function GetObjectPosition(obj) { var totalTop = 0; var totalLeft = 0; while (obj != document.body) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; return {Left:totalLeft, Top:totalTop}; } Upon tracing into this function i found that the obj parameter is immediatly null - but is *should* have been the DOM object for the input box for the dropdown list that was setup for the report. But it *was* set correctly in the calling function. so there is problem 1.My workaround simply took the above code and created a js file that is included at the bottom of the masterPage with the following noted changes:1) the function GetObjectPosition is redefined to the function below, hence "window.GetObjectPosition = function(obj)". this fixes the null reference issue when the function is called.2) I don't know why but the positioning for a Page based on a Master page does not take into account the controls on the Master Page, so initialize totalTop and totalLeft to the NEGATIVE OFFSET of the original position of the contentarea. 3) the original while loop above runs until "obj = document.body". But for whatever reason, in a MasterPage scenario, it never "sees" document.body so we run until the top of the object tree, which means...4) the final accumulation after the while loop is no longer needed. window.GetObjectPosition = function(obj) { var totalTop = -divMasterContentArea.offsetTop ; var totalLeft = -divMasterContentArea.offsetLeft ; while (obj != null) { // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } return {Left:totalLeft, Top:totalTop}; }
Free Windows Admin Tool Kit Click here and download it now
May 14th, 2009 1:49am

This solution takes the mouse position and put the calendar on it.< script language="javascript" type="text/javascript">window.GetObjectPosition = function(obj) {var totalTop = 1;var totalLeft = 0;if (obj != null) {while (obj != document.body){// Add up the positiontotalTop = event.clientY-MasterHeight;totalLeft = event.clientX-MasterLeft;// Prepare for next iterationtry { obj = null; obj = obj.offsetParent; }catch (e) { //We can't calculate things right because it's hosed, so fix it. break; } if (obj = null) break;}}
June 24th, 2009 7:21pm

I could get close with some of the other solution. But my reportviewer wasnt in the same place on every page, so I ended up putting it as the last bit of code inside the <content>. I would then tweak the number in the return statment per page. I am a total javascript novice, so there is probably a better way but maybe this will help someone else. <script language="javascript" type="text/javascript"> window.GetObjectPosition = function(obj) { var totalTop = 0; var totalLeft = 0; var totalTop2 = 0; var totalLeft2 = 0; while (obj != document.body) { try{ // Add up the position totalTop += obj.offsetTop; totalLeft += obj.offsetLeft; // Prepare for next iteration obj = obj.offsetParent; } catch(e) { //Most important hack... ehh, fix return {Left:totalLeft - 105, Top:44}; break; } } } </script>
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2009 12:47am

this bug is not for js this is something else the problem comes form the iis 7 You encounter JavaScript error when loading your report page with ReportViewer. Image buttons such as calendar appear as red 'X'. Reserved.ReportViewerWebControl.axd httpHandler is added to System.Web section of the Web.Config file. In IIS7 try this link it will help cause it works for me http://otkfounder.blogspot.com/2007/11/solving-reportviewer-rendering-issue-on.html Solving ReportViewer Rendering Issue on IIS7 Applies to: Internet Information Services 7.o (IIS7) Microsoft Report Viewer Redistributable 2005 Symptoms: Unable to render ReportViewer on ASP.NET Web pages while running on IIS7. You have no problem viewing your reports when running on debug mode with your Visual Studio 2005. You are able to view your reports on Report Manager but not able to view them on IIS7. You encounter JavaScript error when loading your report page with ReportViewer. Image buttons such as calendar appear as red 'X'. Cause: When the ReportViewer control is added to Web Form (.aspx), theReserved.ReportViewerWebControl.axd httpHandler is added to System.Web section of the Web.Config file. In IIS7, it should be added under System.Webserver section. IIS7 Handler Mappings does not contain Reserved.ReportViewerWebControl.axd httpHandler, and therefore unable to render the ReportViewer elements needed by the JavaSript. Resolution: OpenInternet Information Services (IIS) Managerand select your Web application. UnderIISarea, double-click onHandler Mappingsicon. At theActionpane on your right, click onAdd Managed Handler. At theAdd Managed Handlerdialog, enter the following:Request path:Reserved.ReportViewerWebControl.axdType:Microsoft.Reporting.WebForms.HttpHandlerName:Reserved-ReportViewerWebControl-axd ClickOK. Reserved-ReportViewerWebControl-axd handler is now added to your Handler Mappings list. Notice that the following line has also been added to your Web.config file under the system.webserver's handler section: <add name="Reserved-ReportViewerWebControl-axd" path="Reserved.ReportViewerWebControl.axd"verb="*" type="Microsoft.Reporting.WebForms.HttpHandler" resourceType="Unspecified"/> Run your report again. Iam Not a Civilized Man Iam the Civilization it self White or Balck, Life or Died and 0 or 1 thats MY life iam an Object in Object Oriented Life 01001011 10011011
August 26th, 2009 8:38am

Hi All,I had a report viewer inside a content page which was style="position:absolute;"I found that i didn't get the js error as above but the calendar popout was not appearing.The popout control is actually contained within an iframe so i used the following code on pageLoad to set the zindex of the iframe: function pageLoad() { var iFramesArr = document.getElementsByTagName("iframe"); for (var i = 0; i < iFramesArr.length; i++) { iFramesArr[i].style.zIndex = "500000"; } } If you have your own iframe on the page and dont want this to be effected just add this into the loop: if (iFramesArr[i].id != "MyIframeId") { iFramesArr[i].style.zIndex = "500000"; }
Free Windows Admin Tool Kit Click here and download it now
October 12th, 2009 1:50pm

hi there, i found the problem is that if the report viewer is absolute positioning it does not works. Just change it to static positioning. It works. Enjoy....
April 2nd, 2010 11:30am

OK - so exactly how do you change the positioning to static? Positioning is not a property of the ReportViewer control, so could you please elaborate?Planet Earth is blue... for a little while longer
Free Windows Admin Tool Kit Click here and download it now
October 25th, 2010 1:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics