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

posted @ Sunday, June 01, 2008 2:48 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 6 and type the answer here:
 

Live Comment Preview:

 
«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456