locked
Printing working on XP and not on Windows 7 RRS feed

  • Question

  • User1863994004 posted

    Hi people. Yesterday i have windows XP and making my application on it. Today i preinstall and now i'm using Win 7. In my application i have script that connect me with the print API and it was working yesterday. Today it is not. I have made no changes. No errors show. No mistakes. Nothing. The differenced between today and yesterday are: The OS and the version of the Chrome broweser. I really don't know how to fix having in mind that i take the print script from the internet( of course i fixed it little bit). Here's the code:

    if (error_number == 1) 
                {      
                    Label_Result1_AsDc.Text = GetLocalResourceObject("Label_Result1_AsDcResource1.Text").ToString();
                    Label_Result1_AsDc.Visible = true;
                    Label_Member_AsDc.Visible = true;
    
                    // script for accessing the Print API
                    StringWriter sw = new StringWriter();
                    HtmlTextWriter hw = new HtmlTextWriter(sw);
                    Panel_AD_AsDc.RenderControl(hw);
                    //GridView_Search_Srch.VerifyRenderingInServerForm(hw);     
                    string gridHTML = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<script type = 'text/javascript'>");
                    sb.Append("window.onload = new function(){");
                    sb.Append("var printWin = window.open('', '', 'left=0");
                    sb.Append(",top=0,width=1000,height=600,status=0');");
                    sb.Append("printWin.document.write(\"");
                    sb.Append(gridHTML);
                    sb.Append("\");");
                    sb.Append("printWin.document.close();");
                    sb.Append("printWin.focus();");
                    sb.Append("printWin.print();");
                    sb.Append("printWin.close();};");
                    sb.Append("</script>");
                    ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
                    //Panel_AD_AsDc.PagerSettings.Visible = true;
                    //Panel_AD_AsDc.DataBind();
                }

    error_number here is coming from stored procedure. If it is 1 so the sp executed successfully.

    and overriding a method:

    public override void VerifyRenderingInServerForm(Control control) //overriding the method so can be used for printing
    {
    return;//base.VerifyRenderingInServerForm(control); 
    }



    Thursday, August 9, 2012 12:06 PM

Answers

  • User1954304945 posted

    Hi, please set breakpoints to your codes and debug them. Additionally,

    error_number here is coming from stored procedure
    after moving the web application to another computer, please modify your SQL connection string so that the application can find the database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2012 11:11 PM

All replies

  • User1954304945 posted

    Hi, please set breakpoints to your codes and debug them. Additionally,

    error_number here is coming from stored procedure
    after moving the web application to another computer, please modify your SQL connection string so that the application can find the database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2012 11:11 PM
  • User1863994004 posted

    You are right. I change the connection string and somehow i fixed it. Thank you.

    Tuesday, August 14, 2012 3:46 AM