for (int i = 0; i < colloa.Count; i++)
{
LinkButton lb = new LinkButton();
lb.Text = colloa[i].AttachmentName;
lb.CommandArgument = colloa[i].AttachmentID.ToString();
lb.Click += new System.EventHandler(Button1_Click);
Literal lt = new Literal();
lt.Text = "<br>";
this.attachment.Controls.Add(lt);
this.attachment.Controls.Add(lb);
}
//下载
public void Button1_Click(object sender, EventArgs e)
{
int attchmentId = 25;// int.Parse();
TradeCredit.CoreLibrary.BLL.O_Attachment oaBll = new TradeCredit.CoreLibrary.BLL.O_Attachment();
TradeCredit.CoreLibrary.Entity.O_Attachment oa = oaBll.GetModel(attchmentId);
String savePath = Server.MapPath(oa.Path); //@"C:/inetpub/wwwroot/tc/upload/";
Down(savePath,oa.AttachmentName );
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
string sendFileID = Request.QueryString["sendFileID"];
if (null != sendFileID && sendFileID.Length > 0)
{
//查看回复
this.FileContent.Disabled = false;
InitWriteBackData(sendFileID);
}
}
动态的添加 LinkButton lb = new LinkButton();控件。开始添加控件的方法放在!IsPostBack里面,结果不能调用方法,而且该控件自动消失。后来查了一下,原来动态加载控件、添加事件,这些东西要写在!isposeback外面。