locked
Export To Excel In Update Panel RRS feed

  • Question

  • User9245650 posted

    Hi All,

    I have developed a Server Control that inherits off GridView.  it has an export to excel facility, which is handled when the user clicks an ImageButton, which is contained within the BottomPager Row of the Grid.  This all works fine until I put it in an Update Panel where I get a 

    Uncaught Sys.WebForms.PageRequestManagerParserErrorException error.

    I have read a number of posts none of which have solved my problem including.

    Getting a reference to the ImageButton Control, 

      Protected Overrides Sub OnPreRenderComplete(e As System.EventArgs)
        MyBase.OnPreRenderComplete(e)
        Dim table As Control = FGV1.Controls(0)
        Dim pagerControlAt As Integer = table.Controls.Count - 1
        Dim pagerCell As Control = table.Controls(pagerControlAt)
        Dim excelImageBtn As ImageButton = CType(pagerCell.FindControl("excelImage"), ImageButton)
        Dim excelImageId As String = excelImageBtn.ClientID
        Dim trigger As PostBackTrigger = New PostBackTrigger()
        trigger.ControlID = excelImageBtn.ClientID
        UpdatePanel1.Triggers.Add(trigger)
        'excelImageBtn.Visible = False
        errorLabel.Text = excelImageId
      End Sub

    I have tried with ID and ClientID no difference. I have Overriden VerifyRenderingInServerForm and set EnableEventValidation="false" Any help would be much appreciated.

    Tuesday, February 7, 2012 6:16 AM

Answers

All replies

  • User877341716 posted

    Hi,

    Pls use the ImageButton with ScriptManager.RegisterAsyncPostbackcontrol method. See link below for sample

    http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerasyncpostbackcontrol.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 7, 2012 6:28 AM
  • User498534395 posted

    Try these

    http://forums.asp.net/t/1701698.aspx/1?Export+Data+FROM+C+Data+set+or+DataTable+TO+Excel+xlsx+or+Excel+2010

    Tuesday, February 7, 2012 6:39 AM
  • User3866881 posted

    Hello simcoles1:)

    If you are sure that your proj can properly work without an UpdatePanel,please put both imagebutton as well as the other controls into the UpdatePanel and have a try。

    Reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 8, 2012 8:17 PM