My project is quite simple and contains one webform only. Here is my code
--------------- Default.aspx ------------------------------------
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2008.1.415.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<telerik:RadToolBar ID="RadToolBar1" runat="server">
<CollapseAnimation Duration="200" Type="OutQuint" />
<Items>
<telerik:RadToolBarButton runat="server" Text="Download Excel" Value="DOWNLOADEXCEL">
</telerik:RadToolBarButton>
<telerik:RadToolBarButton runat="server" Text="Download PDF" Value="DOWNLOADPDF">
</telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
</div>
</form>
</body>
</html>
------------------------------------------------------------------------
---------------Default.aspx.vb--------------------------------------------
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
If e.Item.Value = "DOWNLOADEXCEL" Then
Dim file As System.IO.FileInfo = New System.IO.FileInfo("C:\Test.jpg")
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End() 'if file does not exist
Else
Dim file As System.IO.FileInfo = New System.IO.FileInfo("C:\Test.png")
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End() 'if file does not exist
End If
End Sub
End Class
------------------------------------------------------------------------
Please help me how to solve this problem.
Thanks & Regards,
Louis