HOW TO ALLOW USERS TO DOWNLOAD DATA FROM A SITE IN ASP.NET

Posted by Su_ma_2011 under Regular Expressions on 1/27/2011 | Points: 10 | Views : 1435 | Status : [Member] | Replies : 4
Hi friends,

As the title itself explains.. Can someone plzz tell me how to give dowload option? Thanx

Suchitra


Responses

Posted by: Karthikanbarasan on: 1/27/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Can you explain more on ur requirement... download data means ? do you need to download any attachment or any format ?

Thanks
Karthik
www.f5Debug.net

Su_ma_2011, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/28/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Suchitra

Describe ur full problem . if u want to simple docs to download an in any user .. so simple store in website root folder and link with Download Link Button Then any buddy Download your doc

Thanks & Regard's
Prabhakar

Best Regard's
Prabhakar

Su_ma_2011, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Krkc on: 1/28/2011 [Member] Starter | Points: 25

Up
0
Down
Hello Suchitra,

If you are trying to give an option of downloading an Office document then you can use the below code set.

'Clear the buffer and headers so that we can generate the office document

HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.Charset = ""

If _outputContentType = outputType.Excel Then
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" & _outputFileName)
Else
HttpContext.Current.Response.ContentType = "application/msword"
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" & _outputFileName)
End If


And then use the Response.Write method to write anything you wish.. I mean you can even download your .NET controls data. Ex. for grid you can use

Dim stringWrite As StringWriter = New StringWriter

Dim htmlWrite As Html32TextWriter = New Html32TextWriter(stringWrite)
Response.Write("<center><h1>Page Level Heading</h1></center>")
grdTest.RenderControl(htmlWrite)


Thanks,
Ravi

Su_ma_2011, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Su_ma_2011 on: 1/28/2011 [Member] Starter | Points: 25

Up
0
Down
Hmmm Thanx Ravi

Suchitra

Su_ma_2011, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response