Friday, December 23, 2005

Force Download a pdf file

Dim objFile As System.IO.FileInfo

objFile = New System.IO.FileInfo(Server.MapPath("~/file.pdf"))

Response.Clear()

Response.AddHeader("Content-Length", objFile.Length.ToString())
Response.AddHeader("Content-Disposition", "attachment;filename=file.pdf")

Response.AddHeader("Content-Length", objFile.Length.ToString())

Response.ContentType = "application/octet-stream"

Response.WriteFile(objFile.FullName)

Response.Flush()

Response.End()

Tuesday, December 20, 2005

How to Redirect user to page without querystring,

The following works

Response.Redirect(Request.CurrentExecutionFilePath);

Asp.Net-- Working with Datagrid

1.How to make data grid column hidden

Dim dv As DataView = New DataView
dv = grdEmployees.DataSource.defaultview
Dim dc As DataColumnCollection = dv.Table.Columns
e.Item.Cells(dc.IndexOf(dc("lock_no")) + 1).Visible = False