我有一些ASP.NET代码,它在页面上有一个SSRS报表控件。web应用程序托管在与SSRS托管位置不同的服务器上。我遇到的问题是,当我在Internet Explorer中提取报告时,日期选择器控件不会显示日历,如果我试图在Chrome中提取报告,则日期选择器控件根本不会显示。如果我在文本框中键入日期,报告会正常工作,但是,我们真的希望能够使用日期选择器控件。
有什么可能出错的想法吗?
我相信这个问题与之前的问题不同,因为我不仅问非IE浏览器,还问IE的问题。
当用户单击日期选择器控件时,该控件不会在IE中显示日历。
Wayne E.Pfeffer
------编辑以添加代码示例------
aspx代码为:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Width="100%" Height="100%" AsyncRendering="False">
</rsweb:ReportViewer>
<asp:ScriptManager ID="ScriptManager1" runat="server">
有一个下拉列表,其中选择了一个报告,这是将报告加载到报告查看器中的代码:
protected void loadViewer(string report) {
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc = new CustomReportCredentials(
ConfigurationManager.AppSettings["ReportUser"],
ConfigurationManager.AppSettings["ReportPswd"],
ConfigurationManager.AppSettings["ReportDomain"]);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportURL"]);
ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportPath"] + report;
ReportViewer1.SizeToReportContent = true;
//Get the list of account IDs that the user has viewothertransactions at
List<string> vaIds = new List<string>();
string votAccts = (String)Session["votAccounts"];
string[] aIds = votAccts.Split(',');
foreach (var aId in aIds)
{
vaIds.Add(aId);
}
//Create the list of account ids where the user can only see its orders
List<DropdownOption> acclist = (List<DropdownOption>)Session["searchAccounts"];
string acctIds = "";
if (null != acclist)
{
for (int i = 0; i < acclist.Count; i++)
{
if (!vaIds.Contains(acclist[i].Id))
{
acctIds += acclist[i].Id + ",";
}
}
if (acctIds.Length > 0)
{
acctIds = acctIds.Substring(0, acctIds.Length - 1);
}
}
Users user = (Users) Session["userObject"];
ReportParameter userid = new ReportParameter("Userid", user.Id.ToString());
ReportParameter votAccounts = new ReportParameter("VotAccounts", votAccts);
ReportParameter accounts = new ReportParameter("Accounts", acctIds);
log.Debug("Requesting report '" + report + "'. Parameters - Userid=" + user.Id + " VotAccounts=" + votAccts + " Accounts=" + acctIds);
ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { userid, votAccounts, accounts });
ReportViewer1.ServerReport.Refresh();
}
使用Internet Explorer 11时,您可以尝试兼容模式。尝试在页面上按F12查看使用了哪些浏览器模拟。
我最近在IE上遇到了这个问题,并将问题追踪到报表控件注册的javascript函数。javascript函数将原型方法"Show"添加到"DropDownParamClass"中。函数内部有一行代码,用于检查是否存在"FORM"标记,如果不存在,则放弃函数。。。
// do not show the drop down if the frame has not yet been aded to the form tag
if (floatingIFrame.parentNode.tagName.toUpperCase() != "FORM")
return;
在我的情况下,floatingIFrame.parentNode.tagName返回了一个"DIV"。。。作为一个修复,我只是用一个稍微修改过的版本覆盖了DropDownParamClass.prototype.Show函数(而不是新的解释变量"readyToShowCalendar",它检查DIV或FROM标记),请参阅下面。。。
<script language="javascript" type="text/javascript">
if (typeof (window.DropDownParamClass) !== "undefined") {
//Fix for bug in report viewer control resulting in the Calendar Control not displaying when the calendar icon is clicked.
window.DropDownParamClass.prototype.Show = function () {
var floatingIFrame = document.getElementById(this.m_floatingIframeID);
// do not show the drop down if the frame has not yet been added to the form tag
var readyToShowCalendar = "FORM,DIV".indexOf(floatingIFrame.parentNode.tagName.toUpperCase()) > -1;
if (!readyToShowCalendar) return;
// position the drop down. This must be done before calling show base. Otherwise,
// a scroll bar is likely to appear as a result of showBase which would make the
// position invalid.
var newDropDownPosition = this.GetDropDownPosition();
floatingIFrame.style.left = newDropDownPosition.Left + "px";
floatingIFrame.style.top = newDropDownPosition.Top + "px";
this.ShowBase();
// poll for changes in screen position
this.StartPolling();
};
}
</script>
然后,这个脚本被简单地放置在页面的初始标记下面。在此之后,当单击日历图标时,日历控件似乎会按预期打开。