Forcing A Postback Asp.Net

Posted by Nick LaMarca on Stack Overflow See other posts from Stack Overflow or by Nick LaMarca
Published on 2010-05-12T15:16:28Z Indexed on 2010/05/12 15:24 UTC
Read the original article Hit count: 205

Filed under:
|
|

Please take a look at the following click event...

 Protected Sub btnDownloadEmpl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownloadEmpl.Click
        Dim emplTable As DataTable = SiteAccess.DownloadEmployee_H()
        Dim d As String = Format(Date.Now, "d")
        Dim ad() As String = d.Split("/")
        Dim fd As String = ad(0) & ad(1)
        Dim fn As String = "E_" & fd & ".csv"
        Response.ContentType = "text/csv"
        Response.AddHeader("Content-Disposition", "attachment; filename=" & fn)
        CreateCSVFile(emplTable, Response.Output)
        Response.Flush()
        Response.End()
        lblEmpl.Visible = True
    End Sub

This code simply exports data from a datatable to a csv file. The problem here is lblEmpl.Visible=true never gets hit because this code doesnt cause a postback to the server. Even if I put the line of code lblEmpl.Visible=true at the top of the click event the line executes fine, but the page is never updated. How can I fix this?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about vb.net