Windows Azure 中的 AjaxMethods 不起作用

发布于 2024-11-04 21:22:31 字数 975 浏览 5 评论 0原文

我们正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落花随流水 2024-11-11 21:22:31

好消息是,我认为使用 ajax 控件没有任何限制 - 我已经使用了一些并且它们确实有效。

需要检查的一些事情可能是:

  • 您是否可以使用 Fiddler 查看 HTTP 跟踪 - 当您单击打印按钮时是否有请求发送到服务器?
  • 您可以使用javascript调试器来检查当attachEventForPrint发生时没有报告错误吗?
  • “状态”是否存在任何问题 - 特别是会话存储?

另一件需要检查的事情是是否有一种更易于维护的方式来访问打印按钮 - "$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:

  • can you use Fiddler to view the HTTP trace - is a request being sent to the server when you click on the the print button?
  • can you use a javascript debugger to check that there are no errors being reported when attachEventForPrint occurs?
  • are there any issues here with "State" - especially with Session storage?

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文