我們在使用VS2010中的ReportViewer(rdlc)控件的Azure Web應用程序中顯示報告,該報告運行良好。最近,我的客戶要求我爲ReportViewer捕獲Print事件並在服務器上記錄一個條目。我已經用打印按鈕掛鉤了。當我在本地環境中運行Web應用程序時,這非常有效。但是,在Azure上,Ajax方法永遠不會從客戶端調用。請建議做什麼? Azure環境中的Ajax是否存在限制?Windows Azure中的AjaxMethods不起作用
我註冊頁面上的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);
}
}
我從來沒有使用過Microsoft Ajax,但我使用jQuery和Ajax在我們的MVC應用程序中沒有問題。 – vtortola 2011-05-03 09:31:05