asp.net菜单javascript调用

i have a javascript function that prints out the active grid on a tabcontainer (depending on the active tab)

i can print when i just use a client side call to my print function fine.

instead Now i want to use my asp.net menu and have added a print function.

i want this button press to call my javascript.

The c# code is being called but the javascript just shows that no grid exists yet.

Do have to call the javascript after the page is fully loaded ? if so how?

thanks Damo

Javascript

<script type="text/javascript">
    function PrintGridData() {
        //var Tab_Name = $(".ajax__tab_active").first().attr('id');
        alert($(".ajax__tab_active").first().attr('id'));
        switch ($(".ajax__tab_active").first().attr('id')) // Switch based on the on active Tab ID
        {
            case 'TabContainerMain_Tab_Monitor_tab':
                var printContent = document.getElementById('<%= GridViewMain.ClientID %>');
                break;
            default:
                alert('Printing not supported');
                return;
        }
        if (printContent)  // See if the Grid Exists First
        {
            if (printContent.rows.length > 0) { // See if the Grid contains any rows

                var windowUrl = 'about:blank';
                var UserLoggedIn = $("#lblUser").text()
                var now = new Date();
                var strDateTime = [[AddZero(now.getDate()), AddZero(now.getMonth() + 1), now.getFullYear()].join("/"), [AddZero(now.getHours()), AddZero(now.getMinutes())].join(":"), now.getHours() >= 12 ? "PM" : "AM"].join(" ");
                var windowName = 'Report';
                var AuditPrintDetail = 'Report ' + UserLoggedIn + " " + strDateTime;
                var WinPrint = window.open(windowUrl, windowName, 'left=300,top=300,right=500,bottom=500,width=1000,height=500');
                WinPrint.document.write('<' + 'html' + '><head><link href="assets/css/Main.css" rel="stylesheet" type="text/css" />     <title>' + AuditPrintDetail + '</title> </head><' + 'body  style="background:none !important"' + '>');
                WinPrint.document.write(printContent.outerHTML);
                WinPrint.document.write('<' + '/body' + '><' + '/html' + '>');
                WinPrint.document.close();
                WinPrint.focus();
                WinPrint.print();
                WinPrint.close();
            }
            else {alert("No Results to print!");}
        }
        else {alert("No Grid to print!");}
    }

    function AddZero(num) {return (num >= 0 && num < 10) ? "0" + num : num + "";}
</script>

Markup

<div id="DivMenu">
                    <asp:Menu CssClass="Menu" ID="MenuMain" runat="server" Orientation="Horizontal" OnMenuItemClick="MenuMain_MenuItemClick">
                        <Items>
                            <asp:MenuItem Text="System" Value="System">
                                <asp:MenuItem Text="Logout" Value="Logout"></asp:MenuItem>
                                <asp:MenuItem Text="Print" Value="Print"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Help" Value="Help">
                                <asp:MenuItem Text="About" Value="About"></asp:MenuItem>
                            </asp:MenuItem>
                        </Items>
                        <StaticHoverStyle BackColor="White" ForeColor="Black" />
                        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <StaticSelectedStyle BackColor="White" />
                    </asp:Menu>
                </div>

C#

  protected void MenuMain_MenuItemClick(object sender, MenuEventArgs e)
        {

                if (e.Item.Text == "About")
                {
                    AboutModal.Show();


                }


                if (e.Item.Text == "Logout")
                {
                    //Log the user out

                    FormsAuthentication.SignOut();
                    FormsAuthentication.RedirectToLoginPage();
                }


                if (e.Item.Text == "Print")
                {


                    ScriptManager.RegisterStartupScript(Page, GetType(), "JsStatus", "PrintGridData();", true);


                }
            }