Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:37:33+00:00 2026-06-05T01:37:33+00:00

I have a Datalist control which display thumbnails and a download icon (ImageButton) under

  • 0

I have a Datalist control which display thumbnails and a download icon (ImageButton) under it, Datalist is wrapped under UpdatePanel, When user clicks on download icon I call the following function to allow file to be downloaded at user end

    protected void dtlSearchDetails_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "dtlImgDownload")
        {
            downloadFile(e.CommandArgument.ToString(), "~/uploads/primary/");
        }
}

function :

public void downloadFile(string fileName, string filePath)
{
    Response.ContentType = "application/octet-stream";
    Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", fileName));
    Response.WriteFile(filePath + fileName);
}

Now since the ImageButton / Datalist is wrapped inside UpdatePanel, I have registered it as a postback control with the ScriptManager on Page_Load

if (dtlSearchDetails.Items.Count > 0)
{
    foreach (DataListItem li in dtlSearchDetails.Items)
    {
        ImageButton img = (ImageButton)li.FindControl("dtlImgDownload");
        ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(img);
   }
}

Now when I click the download icon nothing happens and I get this following error in console :

Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message
received from the server could not be parsed. Common causes for this
error are when the response is modified by calls to Response.Write(),
response filters, HttpModules, or server trace is enabled.

But,

There are other controls on the same page like search button, which are outside this UpdatePanel but I have registered them as

<trigger>
    <asp:AsyncPostBackTrigger ControlID="btnKeySearch" />
</trigger>

inside the same updatePanel.

When I click on this search button and then click the download Icon it behaves perfectly fine as expected (download’s the file at client) without and error in console.

I am not able to find out the cause behind this workaround.

Kindly help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:37:35+00:00Added an answer on June 5, 2026 at 1:37 am

    your ImageButton is inside a DataList so you have to do the RegisterPostBackControl inside your DataList‘s ItemDataBound event.

    protected void dtlSearchDetails_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var imgBtn = e.Item.FindControl("dtlImgDownload") as ImageButton;
            ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(imgBtn);
            // your other code goes here.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datalist which display's thumbnails of images and a download icon under
I have the following code which is created with a datalist control: http://jsfiddle.net/vmE2E/1/ But
I have a somewhat complex custom user control, created in C# .NET, which is
I have a datalist control which some controls(ex: button) are in it. I want
i doing asp.net and using vb.net. I have a datalist control which inside it
I have a MultiView control which has a View in which a DataList is
i have a datalist control <ItemTemplate> <asp:Label ID=lblAddressID runat=server Text='<%# Bind(StudentName) %>'/> <asp:Label ID=lbl
I have a datalist control <asp:DataList ID=DataList1 runat=server DataKeyField=AdmissionNo OnCancelCommand=DataList1_CancelCommand1 OnEditCommand=DataList1_EditCommand1 OnUpdateCommand=DataList1_UpdateCommand1 Width=300px> <ItemTemplate>
I have an ASP Datalist with a nested GridView. I am trying to display
I have a datalist with itemtemplate which contains: an anchor and an href tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.