Windows Azure 中的 AjaxMethods 不起作用
我们正在使用 VS2010 中的 ReportViewer (rdlc) 控件在 Azure Web 应用程序中显示报告,该控件运行良好。最近,我的客户要求我捕获 ReportViewer 的打印事件并在服务器上记录一个条目。我已经用打印按钮连接了。当我在本地环境中运行 Web 应用程序时,这非常有效。但是,在 Azure 上,Ajax 方法永远不会从客户端调用。请建议该怎么办? Azure 环境中的 Ajax 有限制吗?
我在代码后面的 Page_Load 上注册页面
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(Pages.Report));
ImageButton btnPrint = new ImageButton();
btnPrint = ((ImageButton)(this.FindControl("ctl00$" + ReportViewer1.ClientID.Replace("_","$") + "$ctl06$ctl06$ctl00$ctl00$ctl00")));
btnPrint.Attributes["onclick"] += "attachEventForPrint();";
}
[AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public static void LogEvent(int pLoggingEvent)
{
// Addded logic to log event
}
,并在 ASPX 文件中在 JS 中添加了以下函数
function attachEventForPrint() {
if (typeof (Report) != "undefined") {
Report.LogEvent(4);
}
}
We are showing reports in our Azure web application using ReportViewer (rdlc) control in VS2010 which is working perfectly. Recently my client asked me to capture the the Print event for ReportViewer and log an entry on the server. I've hooked the with the print button.. This works perfectly when I run the web application on a local environment. However, on Azure, the Ajax method never gets called from client side. Please suggest what to do? Is there a limitation for Ajax in Azure Environment?
I'm registering the Page on Page_Load in code behind
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(Pages.Report));
ImageButton btnPrint = new ImageButton();
btnPrint = ((ImageButton)(this.FindControl("ctl00$" + ReportViewer1.ClientID.Replace("_","$") + "$ctl06$ctl06$ctl00$ctl00$ctl00")));
btnPrint.Attributes["onclick"] += "attachEventForPrint();";
}
[AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public static void LogEvent(int pLoggingEvent)
{
// Addded logic to log event
}
And in ASPX file following function was added in JS
function attachEventForPrint() {
if (typeof (Report) != "undefined") {
Report.LogEvent(4);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好消息是,我认为使用 ajax 控件没有任何限制 - 我已经使用了一些并且它们确实有效。
需要检查的一些事情可能是:
另一件需要检查的事情是是否有一种更易于维护的方式来访问打印按钮 -
"$ctl06$ctl06$ctl00$ctl00$ctl00"
看起来现在或者是在自找麻烦在未来的某个时刻The good news is that I don't think there's any limitation with using ajax controls - I've used a few and they just worked.
Some things to check might be:
One other thing to check is whether there is a more maintainable way to access the print button - the
"$ctl06$ctl06$ctl00$ctl00$ctl00"
just looks like it is asking for trouble either now or at some point in the future