日期:2014-05-16 浏览次数:20437 次
上篇博客介绍了两种方法,但是都没能达到想要的功能,下面给大家介绍一下实际项目中应用的方法!
界面:
三个按钮的html代码:
<div id="toolbar" style="padding:5px;"> <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="btnDownLoad()">下载word文档</a> <asp:LinkButton ID="btnLoad" style="display:none" runat="server" onclick="btnLoad_Click" >下载</asp:LinkButton> <asp:LinkButton ID="btnPreView" style="display:none" CssClass="easyui-linkbutton" runat="server" OnClick="WordtoHtml_Click">预览html</asp:LinkButton> <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:btnPreView()">预览HTML</a> <asp:LinkButton ID="btnRemove" style="display:none" CssClass="easyui-linkbutton" runat="server" OnClick="DelectWord_Click">删除文档</asp:LinkButton> <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="destroyWord()">删除文档</a> </div> <%--文档地址--%> <asp:HiddenField ID="HiddenField1" runat="server" value="" /> <%--文档对应的id--%> <asp:HiddenField ID="HiddenField2" runat="server" value="" /> <%--文档名称--%> <asp:HiddenField ID="HiddenField3" runat="server" value="" />
对应的js代码:
<script type="text/javascript"> //预览 function btnPreView() { var row = $('#dg').datagrid('getSelected'); if (row) { var wordaddress = row.wordAddress; //将获取到的选中行地址赋给隐藏控件 document.getElementById("HiddenField1").value = wordaddress; //js调用后台的click方法 document.getElementById("btnPreView").click(); } else { alert('请选中一条记录进行修改'); return; } } //删除 function