私はここで ac# Web アプリを構築しており、Listview を持っています。クリックするとリストビューを簡単に印刷できるボタンをページに配置したいと思います。これがどのように行われるか誰にも分かりますか?
ありがとう
私はここで ac# Web アプリを構築しており、Listview を持っています。クリックするとリストビューを簡単に印刷できるボタンをページに配置したいと思います。これがどのように行われるか誰にも分かりますか?
ありがとう
There are 2 options that I can think of:
window.print
on window.load
Something like:
Order o = DAL.GetOrderByID(int.Parse(Request.QueryString["OrderID"]));
//output the order in this new page...
On this new page, have a line like this:
window.onload=function(){window.print();};
.print
on the frame. Seems very simple to implement.ボタンクリックイベント内に次のコードを追加してみてください。それが役立つことを完全に願っています。
this.ListView1.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
ListView1.RenderControl(hw);
string ListViewHTML = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload = new function(){");
sb.Append("var printList = window.open('', '', 'left=0");
sb.Append(",top=0,width=800,height=700,status=0');");
sb.Append("printList.document.write(\"");
sb.Append(ListViewHTML);
sb.Append("\");");
sb.Append("printList.document.close();");
sb.Append("printList.focus();");
sb.Append("printList.print();");
sb.Append("printList.close();};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "ListViewPrint", sb.ToString());
this.ListView1.DataBind();