Pages

Tuesday, 22 May 2012

Using reportviewer with modal popupextender in Asp.Net

To show a RDLC report inside a modal popupextender follow these steps.
  1. Instead of attaching the modal popup to the button to show report., attach it to a hidden/dummy button.
  2. On the click of Show Report button,load the data in the reportviewer and call modalpopup.show()
  3. Set the AsyncRendering as false in the reportviewer Designer View.
To make sure that the modal popup does not close when a postback occurs on the reportviewer, e.g. On using functionalities of reportiviewer-next page, search etc. follow these steps.

  1.     1.In the 2nd steps above add the following line of code. This will let us know that the modal pop up is   currently being displayed in the next page load
            ViewState["ModalShow"] = "Show";

 2. In the page load event add the following code. This will check that the modal pop up was shown before the post back using the viewstate property we have added. If it exists then show the modalpopup

      if (ViewState["ModalShow"]!= null && ViewState["ModalShow"].ToString().Equals("Show"))
      {
          ModalPopupExtender.Show();   
      }   


  3. In the close event of the button , add the following line of code . This will make the modal pop up to remain hidden on next post back, as the modal popup has been closed by the user.  
       ViewState["ModalShow"] = "Hide";

Thats it.     

No comments:

Post a Comment