TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Eyad Shahroury
NA
32
2.5k
Ajax Problem With Downloading File
May 16 2020 10:58 AM
I have problem with ajax manager :
JavaScript:
I used this function to allow me download a file from gridview
function
onRequestStart(sender, args)
{
if
(args.get_eventTarget().indexOf(
"imgDownload"
) >= 0)
args.set_enableAjax(
false
);
}
My Ajax Manager:
<telerik:RadAjaxManager ID=
"RadAjaxManager1"
runat=
"server"
LoadingPanelID=
"gridLoadingPanel"
ClientEvents-OnRequestStart=
"onRequestStart"
>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID=
"SearchRadButton"
>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID=
"AttachmentRadGridView"
/>
<telerik:AjaxUpdatedControl ControlID=
"AttachmentRecordRadLabel"
/>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID=
"AttachmentRadGridView"
>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID=
"AttachmentRadGridView"
LoadingPanelID=
"gridLoadingPanel"
>
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
My GridView Where I The button for download exist:
<telerik:GridTemplateColumn HeaderText=
"Request Download"
ItemStyle-HorizontalAlign=
"Center"
>
<ItemTemplate>
<asp:ImageButton ID=
"imgDownload"
runat=
"server"
ImageUrl=
"/images/attachment24.png"
CommandName=
"download_file"
Height=
"22px"
Width=
"22px"
ToolTip=
"Request Download"
CommandArgument=
'<%# Eval("ID") %>'
/>
</ItemTemplate>
</telerik:GridTemplateColumn>
CodeBehind:
Protected
Sub
AttachmentRadGridView_ItemCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Handles
AttachmentRadGridView.ItemCommand
If
e.CommandName =
"download_file"
Then
Dim
ditem
As
GridDataItem =
CType
(e.Item, GridDataItem)
Dim
AttachID
As
Long
=
CLng
(ditem(
"ID"
).Text)
DownloadFileAttachment(AttachID)
End
If
End
Sub
Protected
Sub
DownloadFileAttachment(
ByVal
FileId
As
Long
)
'Dim id As Integer = Integer.Parse(TryCast(sender, LinkButton).CommandArgument)
Dim
bytes
As
Byte
()
Dim
fileName
As
String
, contentType
As
String
Dim
constr
As
String
= dbpath
Using con
As
New
SqlConnection(constr)
Using cmd
As
New
SqlCommand()
cmd.CommandText =
"select FileName, ImageData, FileType from FileStore where FileId=@FileId"
cmd.Parameters.AddWithValue(
"@FileId"
, FileId)
cmd.Connection = con
con.Open()
Using sdr
As
SqlDataReader = cmd.ExecuteReader()
sdr.Read()
bytes =
DirectCast
(sdr(
"ImageData"
),
Byte
())
contentType = sdr(
"FileType"
).ToString()
fileName = sdr(
"FileName"
).ToString() &
"."
& contentType
End
Using
con.Close()
End
Using
End
Using
Dim
path
As
String
= MapPath(
"/Download/"
& fileName)
Response.Clear()
Response.Buffer =
True
Response.Charset =
""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = contentType
Response.AppendHeader(
"Content-Disposition"
,
"attachment; filename="
+ fileName)
Response.BinaryWrite(bytes)
Response.Flush()
Response.
End
()
End
Sub
Downloading file working well , but anything else stoped like filtering gridview ,sorting gridview and etc (look like ajax post back stoped)
how can I force ajax manager working again after downloading file ( after calling onRequestStart)
Please Help me
Thank in advance
Reply
Answers (
3
)
kendo dropdownlist
How can I use autocomplete textbox in "each" loop in table