如何在调用window.open()时隐藏表中的行

时间:2017-02-21 23:10:47

标签: javascript asp.net

我正在修改一个旧应用程序,该应用程序的表包含许多行,包括以下行。 (第一个问题是StackOverflow,所以希望它清楚)

<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>

该应用有一个点击事件,通过调用下面的cmdPrint_Click打印aspx页面上的所有控件/值。将打开一个新窗口,其中包含打印对话框和打印预览。

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);
        }
    }

我的目标是从表中删除打印视图的上一行。我已尝试将volumeAvailable.Visible = false添加到服务器端代码以在显示之前隐藏,但该行仍显示在打印窗口中。我还尝试通过添加document.getElementById(&#39; volumeAvailable&#39;)来设置隐藏行.style.display =&#39; none&#39;但是还没有能够让它发挥作用。

在调用window.open()时,有人可以协助排除这一行吗?感谢。

1 个答案:

答案 0 :(得分:0)

您可以use CSS仅在打印时隐藏元素。要隐藏一行,您可以使用ID selector,如下所示:

http://localhost:8080/Home