How to pass multiple parameter in QueryString in ASP.Net
I wanted to pass 2 parameter value to display pdf file, I am using below code but it is not working.
Protected Sub ViewFile(sender As Object, e As EventArgs)
Dim commandArgs() As String = CType(sender, LinkButton).CommandArgument.ToString.Split(New Char() {Microsoft.VisualBasic.ChrW(44)})
Dim t_orno As String = commandArgs(0)
Dim t_dcno As String = commandArgs(1)
Dim embed As String = "<object data=""{0}{1}"" type=""application/pdf""width=""100%"" height=""660px"">"
embed += "If you are unable to view file, you can download from <a href = ""{0}{1}&download=1"">here</a>"
embed += " or download <a target = ""_blank"" href = ""http://get.adobe.com/reader/"">Adobe PDF Reader</a> to view the file."
embed += "</object>"
ltEmbed.Text = String.Format(embed, ResolveUrl("~/OpenDocs.ashx?t_orno=&t_dcno"), t_orno, t_dcno)
End Sub
OpenDocs.ashx
Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim t_orno As String = Convert.ToString(context.Request.QueryString("t_orno"))
Dim t_dcno As String = Convert.ToString(context.Request.QueryString("t_dcno"))
Dim bytes As Byte()
Dim t_dext As String
dbconn.OpenConnection()
Dim cmd As New SqlCommand()
cmd.CommandText = "select t_orno, t_text, t_dext from t_docs where t_orno=@t_orno AND t_dcno=@t_dcno"
cmd.Parameters.AddWithValue("@t_orno", t_orno)
cmd.Parameters.AddWithValue("@t_dcno", t_dcno)
cmd.Connection = dbconn.con
Dim sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Read()
bytes = DirectCast(sdr("t_text"), Byte())
t_dext = sdr("t_dext").ToString()
dbconn.CloseConnection()
context.Response.Buffer = True
context.Response.Charset = ""
If context.Request.QueryString("download") = "1" Then
context.Response.AppendHeader("Content-Disposition", Convert.ToString("attachment; filename=") & t_orno + t_dext)
End If
context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
context.Response.ContentType = "application/pdf"
context.Response.BinaryWrite(bytes)
context.Response.Flush()
context.Response.[End]()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property