Search code examples
javascriptasp.netreportviewer2008

How to get iframe onload event in asp.net


I am using Reportviewer to view SSRS reports on my .aspx page. Since this reportviewer is renders as iframe in the browser. I want call some javascript function every time iframe gets loaded.

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

Solution

  • Not sure if this will help since I've never used ReportViewer but if you have access to the server side page then do the following:

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

    On your javascript file add the following:

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