Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com

Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
            ///<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;
            }
 
Posted on Sunday, June 1, 2008 2:48 PM ASP.NET , CSS/DHTML/JavaScript | Back to top


Comments on this post: Helper function to Print Page using JScript(including inside frame)

# re: Helper function to Print Page using JScript(including inside frame)
Requesting Gravatar...
Hey, that was interesting,

so this is how print button works in different websites,I simply never thought about How it was implemented

Thanks for writing, most people don't bother.
Left by web development company on Aug 18, 2009 2:33 AM

# re: Helper function to Print Page using JScript(including inside frame)
Requesting Gravatar...
This is by far the best looking site I’ve seen. It was completely easy to navigate and it was easy to look for the information I needed. Fantastic layout and great content!
Left by Generic Oxytrol on Dec 20, 2010 3:07 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net