Link to home
Start Free TrialLog in
Avatar of M3mph15
M3mph15Flag for Australia

asked on

Javascript error

Hi all,

I have a page with a gridview on it that shows some search results. Below the gridview is a radio button list for the print options and a button. What i want to do is print the gridview but without the radiobuttonlsit and the button.

What i have done is put a Literal Control in the head section of the page and on the click of the button i set the text of the literal control with a javascript statement.
            LitJs.Text = "<script type=""text/javascript"">" & _
                        "var tbl = document.getElementById('<%=tblPrint.ClientID %>');" & _
                        "tbl.style.visibility = ""hidden"";" & _
                        "window.print();" & _
                        "tbl.style.visibility = ""visible"";" & _
                        "<" & _
                        "/" & "script>"
I have the radio button list and the button in a html table called tblPrint (see attached code). So i am trying to hide the table, print the page and then show the table.

Now when i click the button it stops on the line tbl.style.visibility = "hidden"; and gives the error "Microsoft JScript runtime error: Object required"

Thanks in advance
-M3mph15
<table style="width: 100%;" runat="server" id="tblPrint" >
            <tr>
                <td class="style1">
                    &nbsp;
                </td>
                <td class="style2">
                    &nbsp;
                    <asp:RadioButtonList ID="rblPrint" runat="server" Font-Names="Arial" 
                        Font-Size="Small" Width="160px" Height="70px">
                        <asp:ListItem>Print List</asp:ListItem>
                        <asp:ListItem>Print Details</asp:ListItem>
                        <asp:ListItem Value="Print Address Label">Print Address Label</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td>
                    &nbsp;
                    <asp:Button ID="btnPrint" runat="server" Text="Print" Font-Names="Arial" />
                </td>
            </tr>
        </table>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GreymanMSC
GreymanMSC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M3mph15

ASKER

Fantastic Solution. Thankyou very much.
Avatar of GreymanMSC
GreymanMSC

You are welcome.