在新弹出页面下载

源代码
 1 <div id="icaption">
 2         <div id="title">
 3             XML配置管理
 4         </div>
 5         <a id="btn_add" title="添加菜单" runat="server" href="AddSampleXml.aspx"></a>
 6     </div>
 7     <div id="itable">
 8         <asp:GridView ID="gv_Menu" runat="server" GridLines="None" BorderWidth="0px" CellPadding="0"
 9             CellSpacing="1" align="center" AutoGenerateColumns="false" OnRowCommand="gv_department_RowCommand">
10             <Columns>
11                 <asp:TemplateField HeaderText="名称">
12                     <ItemTemplate>
13                         <%#((System.Data.DataRowView)Container.DataItem)["ACTION"]%>
14                     </ItemTemplate>
15                     <ItemStyle Width="25%" />
16                 </asp:TemplateField>
17                 <asp:TemplateField HeaderText="下载">
18                     <ItemTemplate>
19                         <a href="xmlDetails.aspx?item=<%#Eval("Id") %>">下载</a>
20                     </ItemTemplate>
21                     <ItemStyle Width="25%" />
22                 </asp:TemplateField>
23                 <asp:TemplateField HeaderText="描述">
24                     <ItemTemplate>
25                         <%#((System.Data.DataRowView)Container.DataItem)["DESCRIPTION"]%>
26                     </ItemTemplate>
27                     <ItemStyle Width="25%" />
28                 </asp:TemplateField>
29                 <asp:TemplateField HeaderText="操作">
30                     <ItemTemplate>
31                         <a href="AddSampleXml.aspx?ID=<%#Eval("ID") %>" title="编辑">
32                             <img src="../App_Themes/images/btn_edit.png" alt="编辑" border="0" />
33                         </a>
34                         <asp:LinkButton runat="server" CommandName="Del" CommandArgument='<%#Eval("ID") %>'
35                             OnClientClick="return window.confirm('您确定要删除该xml吗?')" ID="lkDelete" CausesValidation="false"
36                             ToolTip="删除"><img src="../App_Themes/images/btn_delete.png" border="0" />
37                         </asp:LinkButton>
38                     </ItemTemplate>
39                     <ItemStyle Width="25%" />
40                 </asp:TemplateField>
41             </Columns>
42             <RowStyle CssClass="tr3" Font-Size="12px" Height="28px" />
43             <HeaderStyle CssClass="itable_title" />
44             <EmptyDataTemplate>
45                 <tr class="itable_title">
46                     <th width="25%">
47                         名称
48                     </th>
49                     <th width="25%">
50                         查看
51                     </th>
52                     <th width="25%">
53                         描述
54                     </th>
55                     <th width="25%">
56                         操作
57                     </th>
58                 </tr>
59                 <tr class="tr3">
60                     <td class="grid_no_result" colspan="4">
61                         <span>当前没有查询记录</span>
62                     </td>
63                 </tr>
64             </EmptyDataTemplate>
65         </asp:GridView>
66     </div>

新页面的后台

新页面后台
 1     BLL.NeoSampleXmlBll bll = new BLL.NeoSampleXmlBll();
 2     protected void Page_Load(object sender, EventArgs e)
 3     {
 4         if (!string.IsNullOrEmpty(Request.QueryString["item"]))
 5         {
 6             DataTable dt = bll.GetNeoSampleXmls(Request.QueryString["item"]);
 7             if (dt == null)
 8             {
 9                 return;
10             }
11             string content = dt.Rows[0]["content"].ToString();
12             string action = dt.Rows[0]["action"].ToString();
13             XmlDocument doc = new XmlDocument();
14             doc.LoadXml(content);
15             string s = doc.OuterXml; ;
16             StringWriter sw = new StringWriter();
17             sw.WriteLine(s);
18             Response.AddHeader("content-disposition", "attchment;filename=" + action + ".xml");
19             Response.ContentEncoding = Encoding.GetEncoding("gb2312");
20             Response.ContentType = "application/xml";
21             Response.Write(sw.ToString());
22             Response.Flush();
23             Response.End();
24         }
25     }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值