Hi All

Using Visual Studio 2008, C#, .Net 3.5 on IIS.

I have spent ages trying to find how to print from a web page from a
browser without using Javascript without much success. Examples all
appear to be printing from Windows apps. In the end I found this and
it appears to work (if not perfectly it does work).

I have a web page that consists of a set of DropDownList boxes,
labels, text boxes and a datagrid, a search button  and a 'Print'
button. All work fine.

The print button code behind is

      Page.ClientScript.RegisterClientScriptBlock(GetType(),
"Impression", "window.print()", true);

This causes the page to be printed as it is shown on the page.

My problem is that I want to hide certain components from the print
such as the DropDownList boxes and only print certain components such
as the DataGrid.

I have tried using the .Visible attributes of various components in
teh Print Button code behind. Eg

      labelTable.Visible = true;
      tblSelectOptions.Visible = false;
      btnDataPrint.Visible = false;
      Page.ClientScript.RegisterClientScriptBlock(GetType(),
"Impression", "window.print()", true);
      labelTable.Visible = false;
      tblSelectOptions.Visible = true;;
      btnDataPrint.Visible = true;;


However this does not appear to work as all components on the page are
printed

Can anyone please tell me if what I am trying to do is possible and if
so How or alternatively point me in the direction of a site that has
an example of Web page Printing.

Many thanks in advance for any help offered

Regards

Iain

Reply via email to