the process:
- User opens web page, which contains an
asp:LinkButton
(download) and anasp:Button
(next). - "next" is disabled.
- User clicks "download". PDF file is generated in memory and issued as a download.
Need: enable "next"
Problem:
- can't download using javascript - must be server-side
- can't affect elements on web page using server-side without response.redirect
- can't issue a response.redirect because httpheaders have already been issued as part of step one.
I could go to a new page using "next" if it were enabled, but I want it disabled until the download is done.
Some relevant code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If SessionHelper.PrintedEnvelope Or SessionHelper.PrintedTemplate Then
Me.btnNext.Enabled = True
Me.btnNext.CssClass = "nextButton"
Else
Me.btnNext.Enabled = False
End If
End Sub
Protected Sub btnEnvelopeTemplate_Click(sender As Object, e As EventArgs) Handles btnEnvelopeTemplate.Click
Try
SessionHelper.PrintedTemplate = True
Dim m As System.IO.MemoryStream = DeliveryHelper.generateEnvelope(True, "English")
Dim data As Byte() = m.ToArray
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/download"
Response.AppendHeader("Content-Length", data.Length.ToString())
Response.AppendHeader("Content-Disposition", "attachment; filename=" + "EnvelopeTemplate.pdf")
Response.AppendHeader("Accept-Ranges", "bytes")
Response.OutputStream.Write(data, 0, data.Length)
If Response.IsClientConnected Then
Response.Flush()
' Response.End()
End If
Catch ex As Exception
'stuff here
End Try
End Sub
I'm open to jquery ideas, too.