在asp.net中打印LinkBut​​ton [英] Print LinkButton in asp.net

查看:65
本文介绍了在asp.net中打印LinkBut​​ton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:LinkButton ID="lbnPrint" runat="server" class="msLinkButton" OnClientClick="CallPrint();"

                                TabIndex="9" Text="Print"></asp:LinkButton>







function CallPrint()
{
      var lbnCreatereport = document.getElementById('ctl00_ContentPlaceHolder_lbnCreatereport');
      if (lbnCreatereport != null)
      {
           lbnCreatereport.style.display = 'none';
      } 
     var lbnSave = document.getElementById('ctl00_ContentPlaceHolder_lbnsave');

      if (lbnSave != null)
      {
       lbnSave.style.display = 'none';
      }
     var lbnCancel = document.getElementById('ctl00_ContentPlaceHolder_lbncancel');

     if (lbnCancel != null)
     {
       lbnCancel.style.display = 'none';
     }

     var lbnSubmit = document.getElementById('ctl00_ContentPlaceHolder_lbnsubmit');

     if (lbnSubmit != null)
     {
        lbnSubmit.style.display = 'none';
     }
     var lbnPrint = document.getElementById('ctl00_ContentPlaceHolder_lbnprint');

     if (lbnPrint != null)
     {
        lbnPrint.style.display = 'none';
     }
     var txtSDName = document.getElementById('ctl00_ContentPlaceHolder_txtSDName');

     if (txtSDName != null)
     {
        txtSDName.style.border = 'none';
        txtSDName.disabled=false ;
        txtSDName .readOnly=true;

     }
             var display_setting = "'', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=1,status=0,resizable'";
            var content_innerhtml = document.getElementById("printme").innerHTML;
            var document_print = window.open("", "", display_setting);
            document_print.document.open();
            document_print.document.write(content_innerhtml);
            document_print.document.write('</body></html>');
            document_print.print();
            document_print.document.close();
            return false;
    }



我尝试使用print linkbutton,我使用javascript为Print LinkBut​​ton编写了代码.当单击打印链接"按钮时,将打开新窗口,这里的问题是打开新窗口后,主页正在刷新,并且主页中的数据丢失,并且还在新窗口中打开了一个消息框,在该窗口中并取消Buttons.当单击取消"按钮时,它也会刷新主页.
我想,我们为打印弹出式窗口编写了javascript,为什么在打开新窗口并在新窗口中取消按钮时刷新主页.

请任何人帮助我



Hi, I tried on print linkbutton, I wrote the code using javascript for Print LinkButton. When clicking on the Print Linkbutton it''s open the new window , The problem here is after opening the new window , the Main page is refreshing and lose data in main page,and also in new window open a message box , in that Print and cancel Buttons . when click on the cancel button and it refreshing the main page also.
I think , we wrote the javascript for print popup, why refreshing the main page when opening the new window and cancel button in new window.

Please any one help me

推荐答案

服务器控件一定会在单击时回发.您需要改用HTML控件

A server control will surely postback on click. You need to use a HTML control instead

<input type="submit" value="Print"  önclick="return CallPrint();">
                                 name="Print"/></input>






锚标签




OR

anchor tag

<a href="#Foo"  önclick="runMyFunction(); return false;">Do it!</a>


这篇关于在asp.net中打印LinkBut​​ton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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