【发布时间】:2014-12-09 09:39:22
【问题描述】:
我在分层网格 (Telerik RadGrid) 中有一个名为 Download 的链接按钮。我计划在该链接按钮的单击事件中下载文件。一切正常,直到我在页面内放置更新面板。即使页面包含更新面板,我如何下载 word 文件。以下是我正在使用的代码:
在项目命令中
If e.CommandName = "lnkdwnload" Then
objdbconn.ExecuteNonQuerySQL(msSql)
Response.ContentType = "application/msword"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & myfile.Name)
Response.AppendHeader("Content-Length", myfile.Length.ToString())
Response.WriteFile(myfile.FullName)
Response.End()
End If
在项目数据绑定中
If e.Item.ItemType = GridItemType.Item Or e.Item.ItemType = GridItemType.AlternatingItem Then
If e.Item.OwnerTableView.Name = "contactentry" Then
Dim lnk As LinkButton = Nothing
lnk = DirectCast(e.Item.FindControl("lnkdwnload"), LinkButton)
If lnk IsNot Nothing Then
ScriptManager.GetCurrent(Me).RegisterPostBackControl(lnk)
End If
End If
End If
【问题讨论】: