Helper function to Print Page using JScript(including inside frame)

            ///<summary>
            /// Helper function to Print Page using JScript(including inside frame) 
            ///</summary>
            ///<param name=”page”></param>
            public static void PrintPage(Page page)
            {
                //In case if page is in frameset, you need to call parent.window.print()
                String script = @”
if (parent!= self)
{ parent.window.print();
}
else
{
    window.print();
}
;
                RegisterOnceStartupScript(page,TypeForClientScript(), MethodBase.GetCurrentMethod().Name,script,true);
            }
            public static bool RegisterOnceStartupScript(Page page, Type type,   string key, string script, bool addScriptTags)
            {
                bool bRet=false;
                if(false==page.ClientScript.IsStartupScriptRegistered(type,key))
                {
                    page.ClientScript.RegisterStartupScript(type, key, script, addScriptTags);
                    bRet = true;
                }
                return bRet;
            }