後顯示一個按鈕,我有一個創建頁面的PDF頁面上的按鈕。我想隱藏pdf的按鈕,然後在創建pdf後顯示它。我在代碼隱藏中嘗試了以下內容,但並未隱藏該按鈕。隱藏/點擊Asp.Net
Private Sub PdfPageButton_ServerClick(sender As Object, e As System.EventArgs) Handles PdfPageButton.ServerClick
PdfPageButton.Visible = False
ConvertURLToPDF()
PdfPageButton.Visible = True
End Sub
Private Sub ConvertURLToPDF()
Dim urlToConvert As String = HttpContext.Current.Request.Url.AbsoluteUri
'more code here not displayed...
' Performs the conversion and get the pdf document bytes that you can further
' save to a file or send as a browser response
Dim pdfBytes As Byte() = pdfConverter.GetPdfBytesFromUrl(urlToConvert)
' send the PDF document as a response to the browser for download
Dim Response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
Response.Clear()
Response.AddHeader("Content-Type", "binary/octet-stream")
Response.AddHeader("Content-Disposition", "attachment; filename=ConversionResult.pdf; size=" & pdfBytes.Length.ToString())
Response.Flush()
Response.BinaryWrite(pdfBytes)
Response.Flush()
Response.End()
End Sub
但是我在css中使用[@media print]不顯示我的打印按鈕。壞
你是對的,它確實隱藏了按鈕,但它仍然顯示在pdf上。 – TroyS
哦對 - PDF是當前page_的PDF文件?我們需要知道它是如何生成的,但是我建議你使用CSS來搜索media =「print」 – Widor
你是一個非常有效的天才。我添加了這個... Dim urlToConvert As String = HttpContext.Current.Request.Url.AbsoluteUri&「?IsPdf = 1」和查詢字符串到PageLoad事件並且Wa La工作。謝謝。 – TroyS