This is a migrated thread and some comments may be shown as answers.

GridAttachment Column Javascript Parser Error

2 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sreekanth
Top achievements
Rank 1
Sreekanth asked on 19 Jan 2012, 02:38 PM
Hi,

Currently am working on the GridAttachment Column ,I placed the Rad Grid inside the Update Panel, On the Item Command event am d,i have written the download attachment code.But after clicking on Attachment item link in the Rad Grid amd getting Javascript Parser exception.

Please cgo thtough the below code,suggest me if am doing wrong

Aspx

 

 

<asp:ScriptManager ID="ScriptManager1" runat="server">

 

 

 

</asp:ScriptManager>

 

 


<

 

 

asp:UpdatePanel ID="upd" runat="server">

 

 

 

 

<ContentTemplate>

 


<

 

 

telerik:RadGrid ID="RadGrid2" AllowPaging="True"

 

 

 

ShowFooter="true" runat="server" AutoGenerateColumns="False" AllowSorting="True"

 

 

 

PageSize="3" GridLines="None" OnItemCommand="RadGrid2_ItemCommand" CellPadding="0" AllowAutomaticInserts="true"

 

 

 

AllowAutomaticUpdates="true">

 

 

 

<ClientSettings AllowRowsDragDrop="true"></ClientSettings>

 

 

 

<MasterTableView DataKeyNames="Id" AutoGenerateColumns="false" CommandItemDisplay="Top">

 

 

 

 

<Columns>

 

 

 

 

<telerik:GridAttachmentColumn DataSourceID="Id"

 

 

 

MaxFileSize="1048576"

 

 

 

EditFormHeaderTextFormat="Upload File:"

 

 

 

HeaderText="Download"

 

 

 

AttachmentDataField="BinaryData"

 

 

 

AttachmentKeyFields="Id"

 

 

 

FileNameTextField="AttachmentFile"

 

 

 

DataTextField="AttachmentFile"

 

 

 

UniqueName="AttachmentFile">

 

 

 

</telerik:GridAttachmentColumn >

 

 

 

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

 

 

</telerik:RadGrid>

 

 

 

</ContentTemplate>

 

 

 

</asp:UpdatePanel>

 


CS

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

 

if (!IsPostBack)

 

{

 

RadGrid2.DataSource =

 

TestData.GetEmployeeData();

 

RadGrid2.DataBind();

}

}


 

 

protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

 

//upd.Update();

 

 

 

if (e.CommandName == "DownloadAttachment")

 

{

 

 

LinkButton btn = e.CommandSource as LinkButton;

 

 

 

 

 

string fileName1 = "images\\about.png";

 

 

 

/*

 

For testing purpose we took only a test image

* you can look at the e.CommandSource to know which row was clicked by

* checking the linkbutton.Text property(LinkButton btn = e.CommandSource as LinkButton;)

*/

 

 

FileInfo file = new FileInfo(Server.MapPath(fileName1));

 

 

 

NameValueCollection imageExtensions = new NameValueCollection();

 

imageExtensions.Add(

 

".jpg", "image/jpeg");

 

imageExtensions.Add(

 

".gif", "image/gif");

 

imageExtensions.Add(

 

".png", "image/png");

 

 

 

MemoryStream ms = new MemoryStream();

 

 

 

 

if (imageExtensions.AllKeys.Contains(file.Extension))

 

{

Response.Clear();

Response.ContentType = imageExtensions.Get(file.Extension);

Response.AppendHeader(

 

"Content-Disposition", "attachment; filename=" + file.Name);

 

Response.TransmitFile(file.FullName);

Response.End();

}

}

}

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Jan 2012, 03:06 PM
Hello,

This error due to your grid was ajaxify.

Please check this link for how to disable ajax on upload and download.

Thanks,
Jayesh Goyani
0
Sreekanth
Top achievements
Rank 1
answered on 20 Jan 2012, 08:20 AM
Hi,
Here am not using the RadAjax manager in my Code.we are no tsupposed to use RAD AJAX Manager
can you please suggest me the solution that will work with my code,with out RAD AJAX Manager.

Thanks,
Sreekanth
Tags
Grid
Asked by
Sreekanth
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Sreekanth
Top achievements
Rank 1
Share this question
or