0

I'm modifying an older application which has a table with many rows including the following row. (first question asked on StackOverflow, so hoping it's clear)

<tr id="volumeAvailable" class="standardRow">
     <td align="right" colspan="2"><i>Volume Available for TPN/IL=</i></td>
     <td>
         <asp:TextBox ID="txtTotalFluidsLeftInfo" runat="server" style="border:None; text-align:left; color:blue; font-weight:bold;" Text="0" ReadOnly="true" CssClass="NumericTextbox" ToolTip="0" />
     </td>
</tr>

The app has a click event which prints all controls/values on the aspx page by calling cmdPrint_Click below. A new window is opened which contains the print dialog and print preview.

protected void cmdPrint_Click(object sender, EventArgs e)
    {
        try
        {
            string _url = "'./TPNForm.aspx?ID=" + hOrderId.Value + "&type=print'";
            string _target = "'_blank'";
            string _script = "window.open(" + _url + "," + _target + "," + "'status=no, menubar=yes, toolbar=no,scrollbars=1, height=400px,width=600px');";
            ClientScript.RegisterStartupScript(this.GetType(), "onclick", _script, true);
        }
        catch (Exception _ex)
        {
            throw new ApplicationException(_ex.Message);
        }
    }

My goal is to remove the above row from the table for the print view. I've tried adding volumeAvailable.Visible = false to the server side code to hide before displaying but the row still displays in the print window. I've also tried hiding the row by adding document.getElementById('volumeAvailable').style.display='none' but haven't been able to get this to work.

Can anybody assist on a possible way to exclude this row when calling window.open()? Thanks.

back9
  • 3
  • 2

1 Answers1

0

You can use CSS to hide an element only when printing. To hide just the one row, you can use an ID selector, like this:

@media print
{    
    #volumeAvailable
    {
        display: none !important;
    }
}
Community
  • 1
  • 1
John Wu
  • 50,556
  • 8
  • 44
  • 80