Protected Sub View_click(ByVal sender As Object, ByVal e As EventArgs)
Dim id As Integer = Integer.Parse(TryCast(sender, LinkButton).CommandArgument)
Dim lsfilename As String
Dim lsfilepath As String
Dim savePath As String = "c:/Users/Administrator.VCIDEX3/Downloads"
Dim embed As String = "<object data=""{0}"" type=""application/pdf"" align=""center"" width=""500px"" height=""600px"">"
embed += "</object>"
objdbconn.OpenConn()
msSQL = "select Id,FileName,FilePath from tblfiles where Id='" & id & "'"
objODBCDataReader = objdbconn.GetDataReader(msSQL)
If objODBCDataReader.HasRows = True Then
objODBCDataReader.Read()
lsfilename = objODBCDataReader.Item("FileName").ToString
lsfilepath = objODBCDataReader.Item("FilePath").ToString
End If
msSQL = " select * from tblfiles where id='" & id & "' "
ltEmbed.Text = String.Format(embed, ResolveUrl("'" & savePath & "' /q.pdf"))
objdbconn.CloseConn()
End Sub
<asp:Literal ID="ltEmbed" runat="server" />
这里我尝试使用文字查看PDF文件,代码执行和我 正确得到
c:/Users/Administrator.VCIDEX3/Downloads/q.pdf
但是 文件未显示。
答案 0 :(得分:1)
您的文字中有两个参数占位符,即{0}和{1},但您只提供一个值,即ResolveUrl
的结果。如果文本期望要替换两个值,则需要提供两个值。