I created code for converting binary data to pdf my aim is to show error message when date is not avalable in sql otherwise it should pdf file can anyone help me how to do.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to show the message on pdf itself then
Using sdr As SqlDataReader = cmd.ExecuteReader()
if sdr.hasrows then
sdr.Read()
pdf = DirectCast(sdr("BinaryData"), Byte())
ID = sdr("RunId").ToString()
else
pdf = DirectCast("No Data Found", Byte())
end if
回答2:
You might wanna try this
Dim csname1 As String = "PopupScript"
Dim csname2 As String = "ButtonClickScript"
Dim cstype As Type = Me.GetType()
Dim cs As ClientScriptManager = Page.ClientScript
If (Not cs.IsStartupScriptRegistered(cstype, csname1)) Then
Dim cstext1 As String = "alert('Record not found');"
cs.RegisterStartupScript(cstype, csname1, cstext1, True)
End If
You can also use the approach given here http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/executing-javascript-code-from-server
As you can see it will load the script, you either can load that script or can create a function and call it like VB example in telerik or Mix both approaches to suit you.