ASP.NET Web Forms Server Controls
The ASP.NET Web Forms Server Controls package contains a suite of controls and resource to simplify the implementation of common scenarios for providing a controlled printing experience within an ASP.NET Web Forms application/site:
- Installation of the ScriptX Add-on on the client PC including a page crafted to assist the user during the installation process with prompts and screen snips depending upon the browser version being used.
- Initialising print settings such as headers, footers, margins and the printer to use.
- Buttons to initiate printing.
The ASP.NET Web Forms model is one where round-trips to the server are frequent as a click on a client side button results in a post-back to the server where the button click is processed and new content delivered back to the client PC for display.
However, printing is entirely a client PC process and so the ScriptX ASP.NET Web Forms Server Controls all emit javascript and client event handlers that are executed on the client PC. There is never a call back to the server.
This package is dependent upon the following packages:
-
MeadCo ScriptX - installers for web sites
This package provides the installers for the ScriptX binaries and a custom configuration section that also allows you to specify any Advanced Printing publishing license you have purchased - or the evaluation license.
-
MeadCo ScriptX JS Simple Wrapper
This packages provides convenient wrappers on some common ScriptX functionality. It is not dependent on any other libray (such as jQuery).
All of the server controls are provided in the namespace:
MeadCoScriptX:
For convenience, the installer for the Nuget package of the controls adds a reference to this namespace for all pages in your app/site (an update to web.config).
The following controls are provided:
- MeadCoScriptX:ClientPrinting
- MeadCoScriptX:PrintButton
- MeadCoScriptX:PrintPreviewButton
Using licensed features
Some features require an Advanced printing publishing license.
To enable the licensed features, specify your license in the installers config section. For example, to use the evaluation license, edit the config section to include the evaluation license. The section will look like this:
<meadco>
<scriptx>
<clientinstaller filename="~/content/meadco.scriptx/installers/smsx.cab"
version="8,3,0,4
" />
<license
guid="{370000ED-D40C-43D4-B3D3-F2E7D2EFF47D}
"
revision="0"
filename="http://licenses.meadroid.com/
download/{370000ED-D40C-43D4-B3D3-F2E7D2EFF47D}
/mlf" />
</scriptx>
</meadco>
Initialising printing at the client with MeadCoScriptX:ClientPrinting
Initialising printing at the client requires:
- The ScriptX add-on 'factory' object
- Some javascript to set the required print parameters
The section 'Basic printing with ScriptX' illustrates how to do this and while not at all difficult there are tedious aspects such as neatly handling the case of the add-on needs to be installed.
The MeadCoScriptX:ClientPrinting server control simplifies the coding to an intuitive set of attributes:
<MeadCoScriptX:ClientPrinting
ClientValidate="redirect"
InstallHelperUrl="install.aspx"
PrintTemplate="Default"
runat="server">
<PrintSettings
footer="ScriptX Demonstration Page: &p"
header="Date: &D"
headerFooterFont = ""
printer = "HP Color LaserJet 2550n">
<PageSetup
Orientation="landscape"
PaperSource="Tray 1"
PaperSize="A4"
Units = "mm" >
<Margins left="20" bottom="20" top="20" right="20" />
</PageSetup>
</PrintSettings>
</MeadCoScriptX:ClientPrint>
ClientPrinting
Attribute | Description | Default |
ClientValidate |
Specifies whether the ScriptX Add-on is to be installed if the required version isnt already installed. If the value is 'redirect' then if the required version is not available the user will be redirected to the installer page. |
none - no scripted check is made that ScriptX is available. Internet Explorer will prompt to install the add-on if it is not installed or a newer version is required. |
InstallHelperUrl |
The url to redirect to when ClientValidate is 'redirect' and if the required version of ScriptX is not innstalled on the client PC |
"~/MeadCo.ScriptX/InstallFailed.aspx" [the default handlers installed by the package] |
PrintTemplate |
The template to use. May be one of the values Default, Classic, IE7, IE 5, MaxiPT. This attribute specifies the value of the ScriptX templateUrl property |
"Default" |
PrintSettings
Attribute | Description | Default |
footer |
The footer text to use. See the footer reference for details. |
The user's IE default. |
header |
The header text to use. See the header reference for details. |
The user's IE default |
headerFooterFont |
A description of the font to use. The ScriptX reference for headerFooterFont gives full details. |
The user's IE default |
printer |
The printer to use. A publishing license is required to use this attribute. |
The user's default printer |
PageSetup
Attribute | Description | Default |
Orientation |
The paper orientation - "landscape"or "portrait" |
The user's IE default. |
PaperSource |
The name of the paper source to use (e.g. "Tray 1"). A publishing license is required to use this attribute. |
The printer default |
PaperSize |
The name of the paper size to use (e.g. "A4"). A publishing license is required to use this attribute. |
The printer default |
Units |
The measurement units to use for margins - "inches" or "mm". A publishing license is required to use this attribute. |
The user's default units |
Margins
Attribute | Description | Default |
left |
The left margin value in the specified units (may be the users default units). Please note that no margin value can be less than the printer's unprintable margin. |
The user's IE default. |
top |
The top margin value in the specified units. |
The user's IE default |
right |
The right margin value in the specified units. |
The user's IE default |
bottom |
The bottom margin value in the specified units. |
The user's IE default |
Print a document with MeadCoScriptX:PrintButton
The MeadCoScriptX:PrintButton element inherits from the standrad HTML button element so all the standard attributes such as CssStyle work as expected. As expected, the element provides a button that when clicked will cause the current document, a frame or a document downloaded from a url to be printed accordiing to the settings described in the MeadCoScriptX:ClientPrinting element.
The MeadCoScriptX:PrintButton provides a button and printing behaviour with a few simple attributes:
<MeadCoScriptX:PrintButton
Text="Print"
Prompt="false"
runat="server />
PrintButton
Attribute | Description | Default |
Text |
The button text. |
Print. |
Prompt |
Whether the user should be prompted to select a printer. |
True. To use 'false' a publishing license is required. |
Frame |
The name of the frame to be printed. |
None. The host document will be printed. |
DocumentURL |
The url of the document to be printed. |
None. The host document will be printed using printHtml(). This feature requires a publishing license. |
Preview the current page or frame with MeadCoScriptX:PrintPreviewButton
The MeadCoScriptX:PrintPreviewButton element inherits from the standrad HTML button element so all the standard attributes such as CssStyle work as expected. As expected, the element provides a button that when clicked will cause the current document, or a frame to be previewed.
Attribute | Description | Default |
Text |
The button text. |
Print. |
Frame |
The name of the frame to be previewed. |
None. The host document will be previewed. This feature requires a publishing license. |
Improvements and developments
What else would you like to see in the server controls package? Please use the Community Forum or Contact Us to send us your ideas.