2012-02-22 34 views
0

我正在使用Reportviewer在我的.aspx頁面上查看SSRS報告。 由於此reportviewer在瀏覽器中呈現爲iframe。 我想在每次加載iframe時調用一些javascript函數。如何在asp.net中獲取iframe onload事件

I can't use window.onload because the content of reportviewer that is iframes get changed without any postback. 

回答

3

不知道這是否會幫助,因爲我從來沒有用過的ReportViewer,但如果你有機會到服務器端頁面,然後執行以下操作:

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 
     MainIFrame.Attributes.Add("onload", "MainIFrame_OnLoad();"); 
    } 
} 

在JavaScript文件中添加以下內容:

function MainIFrame_OnLoad() { 
    alert('yes!'); 
}