Promoting web printing, some places need to be improved.
using System; using System.Data; using System.Web; using System.Text; using System.Collections; using System.Web.UI; using System.Data.SqlClient; using System.Web.UI.WebControls; using System.Web .Ui.htmlcontrols; usingspace webprint {/// /// This is a scheme that completely utilizes IE own objects to implement web printing, the main data is derived from the data binded by the DataGrid control /// the user can customize the basic elements of the definition of the general report title, headers, footers, and other printed lines per page /// author: KG /// date: 2005.1.1 /// source: www.domanage.com./ // summary> public class clsPrint: System.Web.UI.Page {private string [] sShoulderLeft; private string [] sShoulderCenter; private string [] sShoulderRight; private string [] sFooterLeft; private string [] sFooterCenter; private string [] sFooterRight; private string sPageTitle = ""; private string sSpanColumnList = ""; private int iPageNumber = 30; private DataGrid myDataGrid; private static string pageUrlBase; // Page basic URL public clsPrint () {try {string urlSuffix = Context .Request.url.host; urlsuffix = urlsuffix (Context.Request.ur.port.tostring () == ""? ":": " Context.request.URL.Port); urlsuffix = urlsuffix ( Context.Request.ApplicationPath.toString () == "/" ": Context.request.ApplicationPath); PageURLBase = @" http: // " urlsuffix;} catch {// for design Time}} #region The number of lines displayed //// /// //////////////////////////////////////////>}} set {ipagenumber = value;}} # endregion # region page Title /// /// page Title /// summary> public string pagetitle {get {return spageTitle;} set {spageTitle = value;}} # endregion # region grid control key To merge Columns collection /// /// Grid control key to merge column set, format, 2, 3, 4 ... Split /// summary>
Public string spancolumnlist {get {ran sspancolumnlist;} set {sspancolumnlist = value;}} # endregion # region left eyebrow title, array type [0] [1] ... display order from top to bottom /// /// Page Title /// summary> public string [] Shoulderleft {get {returnift;} set {sshould = value;}} # endregion # region Title, array type [0] [1] ... display order from top to bottom /// /// page Title /// summary> public string [] ShoulderCenter {Get {Return SSHOULDERCENTER;} set {sSholderCenter = value;}} # #REGION Right page eyebrow title, array type [0] [1] ... display order from top to bottom /// /// page Title /// summary> public string [] ShoulderRight {Get {Return SSHOULDERRIGHT;} set {sSHOULDERRIGHT = value;}} # endregion # region left foot title, array type [0] [1] ... display order from top to bottom /// /// page Title /// summary> public string [] footerleft {get {return sfooterleft;}}} # endregion # region Mid-page headline, array type [0] [1] ... display order From top to bottom /// /// page Title /// summary> public string [] footerCenter {get {return sfooterCenter;} set {sfooterCenter = value;}} # endregion # region right foot Title, array type [0] [1] ... display order from above to bottom /// /// page Question /// summary> public string [] footerright {get {return sfooterright;} set {sfooterright = value;}} # endregion # Region Print Grid Control Name /// /// Printing Network Grid Control Name /// summary> public datagrid dgdataGrid {get {return mydatagrid;}}} # endregion # region Modify the contents of the template file, construct print data, overwritten print template /// < Summary> // / Modify the contents of the template file, construct print data, rewrite the print template /// summary> public void printview () {clearview (); stringbuilder htmltext = new stringbuilder (); try {using = New StreamReader (server.mappath (context.request.ApplicationPath) "
//printwindow.htm ") {string line; while ((line = sr.readline ())! = null) {htmltext.append (line);} snr.close ();}} catch {response.write "