下载内部更新Pannel中的Repeater控件中的linkBut​​ton问题 [英] Download linkButton Problem in Repeater control which is Inside Update Pannel

查看:112
本文介绍了下载内部更新Pannel中的Repeater控件中的linkBut​​ton问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个转发器控件,它位于Update Pannel内,这个更新pannel包含异步postBack触发器。这个转发器显示来自某个文件夹的文件。我有项目赞成下载和删除文件。在更新pannel控件中我调用了异步触发器删除文件,因为我想更新重复withot回发它工作正常。但是当我试图下载文件它不工作时,fallowing是它工作的代码当我放置一个按钮并调用相同的方法



  public   void  DownloadFile(  string  filePath)
{
if (File.Exists(HttpContext.Current。 Server.MapPath(filePath)))

{

string fileName = Path.GetFileName(filePath);
Response.ClearHeaders();
Response.ContentType = application / octet-stream;
Response.AddHeader( Content-Disposition attachment; filename = + fileName);
Response.TransmitFile( @ 〜\ Uploads \ + fileName);
// Response.End();
HttpContext.Current.ApplicationInstance。 CompleteRequest();


}





上面的代码是在转发器外面的按钮上工作但是它不适用于转发器中的linkbutton

解决方案

是的。它在updatepanel中不起作用。您必须在updatepanel中添加一个回发触发器。指定转发器的ID controlID。例如:/ b


 <   asp:updatepanel     id   =  YourUpdatePanel    runat   = 服务器 >  

< 触发器 > < asp:postbacktrigger controlid = YourRepeaterControlID / > < / triggers >

< contenttemplate >
<! -
您的中继控制等...
- >

< / contenttemplate > ;

< / asp:updatepanel >


正是我要搜索的内容......很棒......谢谢。!

I have a repeater control which is inside Update Pannel this update pannel contains Asynchronous postBack triggers.this repeater shows the files from certain folder.i have item commends for download and delete files.in the update pannel control i called the asynchronous trigger for delete files because i wanted to update repeated withot postback its working fine.but when i tried to download the file its not working the fallowing is the code its working for when i place a button and call the same method

public void DownloadFile(string filePath)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(filePath)))

            {

              string fileName = Path.GetFileName(filePath);
                    Response.ClearHeaders();
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename="+fileName);
                    Response.TransmitFile(@"~\Uploads\"+fileName);
                    //Response.End();
                    HttpContext.Current.ApplicationInstance.CompleteRequest();


}



The above code is working from the button which is outside the repeater but it is not working for the linkbutton which is in repeater

解决方案

Yes. It will not work inside updatepanel. You will have to add a postback trigger inside updatepanel. specify your repeater's ID controlID. For example something like this:

<asp:updatepanel id="YourUpdatePanel" runat="server">
 
<triggers><asp:postbacktrigger controlid="YourRepeaterControlID" /></triggers>
 
<contenttemplate>
<!--
Your Repeater Control etc...
 -->
</contenttemplate>
 
</asp:updatepanel>


Exactly what i am searching for... Excellent... Thank you.!


这篇关于下载内部更新Pannel中的Repeater控件中的linkBut​​ton问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆