在Reponse之前更改ASP.NET控件的可见性

时间:2018-03-06 15:36:19

标签: asp.net vb.net

我在ASP.NET中有一个简单的按钮事件处理程序,允许用户将电子表格下载到他们的浏览器,同时显示一组与该电子表格的进一步处理相关的控件。代码如下:

Protected Sub btnDownLoadReview_Click(sender As Object, e As EventArgs) Handles btnDownLoadReview.Click
    Dim excelEngine As ExcelEngine = New ExcelEngine()
    Dim mboXLS() As Byte = Session("ScrubDataExcel")
    Dim stream As Stream = New MemoryStream(mboXLS)
    Dim workBookFinal As IWorkbook = excelEngine.Excel.Workbooks.Open(stream)
    Dim fileName As String = UniqueFileName(".xls")
    Dim sURL As String = ConfigurationManager.AppSettings("UploadFileName").ToString() & "_" & fileName

    lblDoYouWishToModify.Visible = True
    btnUploadCorrections.Visible = True
    fupSelectFile.Visible = True
    btnUploadCorrections.Visible = True
    lblYouMayResubmit.Visible = True

    workBookFinal.SaveAs(HttpContext.Current.Server.MapPath(sURL))

    Response.ContentType = "application/xls"
    Response.AppendHeader("Content-Disposition", "attachment; filename=" + sURL)
    Response.TransmitFile(Server.MapPath(sURL))
    Response.End()

End Sub

问题似乎是存在Reponse对象调用。如果我删除这4行,则显示控件。如果我指的是其中一个控件不显示。不会抛出任何错误,但似乎忽略了Visible属性设置。

我尝试将可见设置移动到响应设置之前和之后的位置,但无济于事。

关于这里可能出现什么问题的任何想法?

由于

卡尔

0 个答案:

没有答案