Let the control in updatepanel trigger the PostBack of the entire page

Source: Internet
Author: User
The gridview is wrapped up by updatepanel, but the gridview has a download imagebutton. If it is refreshed locally, the file cannot be downloaded. Code Register the Download button in updatepanel. The whole page is PostBack every time you click it. For ( Int I =   0 ; I <   This . Gridviewsopdocument. Rows. Count; I ++ )
{
Imagebutton imagebuttondownload = (Imagebutton) This . Gridviewsopdocument. Rows [I]. findcontrol ( " Imagebuttondownload " );
If (Imagebuttondownload ! =   Null )
{
(Scriptmanager) (vpjquerymaster) This . Master). findcontrol ( " Scriptmanager1 " ). Registerpostbackcontrol (imagebuttondownload );
}
}

Download Method: Public   Void Filedownload ( String Filepath, String Filename, String Systemfilename)
{
Fileinfo downloadfile
=   New Fileinfo ( This . Applicationphysicalpath + Filepath +   " \\ "   + Systemfilename );
If (Downloadfile. exists)
{
Response. Clear ();
Response. clearheaders ();
Response. Buffer =   False ;
Response. contenttype =   " Application/octet-stream " ;
Response. appendheader ( " Content-Disposition " , " Attachment; filename = "
+ Httputility. urldecode (filename, system. Text. encoding. utf8 ));
Response. appendheader ( " Content-Length " , Downloadfile. length. tostring ());
Response. writefile (downloadfile. fullname );
Response. Flush ();
Response. End ();
}
Else
{
Showajaxmessage ( " Msg_public_download_file_does_not_exist " );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.