Opening a PDF ASP.NET "file is damaged and cannot be opened"

I pulled a PDF and other documents from the database after performing an upload and when I attempted to open the document on a web page I got "file is damaged and cannot be opened."  Well after digging around I found that the Table Adapter in .NET create the stored proc pamarmeter as binary with the BLOG provider type (which was correct) but it defaulted the size to 65k.  I keyed -1 in the size and that changed the parameter to the max size as shown below with DBType as Object.  Basically the document was getting truncated when loaded from the disk to the database.  


Capture Enter Key on ASP.NET TextBox

Here is a method you can pass a text box and a command button to add the onpress event logic.

namespace SURFTHRU
    public static class HTMLControls
        public static void SetEnterButton(TextBox txtBox, Button btn)
                      "if(event.which || event.keyCode) { if ((event.which == 13) || (event.keyCode == 13)) " +
                      "{document.getElementById('" + btn.ClientID + "').click(); return false;}}" +
                      "else {return true}; ");


Disable Button and Enable button after Repsonse.End()

Have you ever rendered and Excel, Word, or PDF document with ASP.NET and disabled the button when the user clicked "Export To Excel" so that they would only click it once?  Then only to find out the the button is still disabled after Response.End() and you cannot enable it again?

Well the only way I found to enable the button again is with a JavaScript timer after x number of seconds. This is not the best solution if your process runs long. If you have found a better way please email me.

The code below will disable the button on an ASP.NET page after a user clicks it. Then a JavaScript will run and enable the button again after 10 seconds.

protected void Page_Load(object sender, EventArgs e)
    BtnPrint.Attributes.Add("onclick", "javascript:"
      + BtnPrint.ClientID + ".disabled=true;"
      + Page.ClientScript.GetPostBackEventReference(BtnPrint, null));

    //Renable the button after 10 seconds
    string Script = @"";

    Script = Script.Replace("$BTNAME", BtnPrint.ClientID);
    Page.ClientScript.RegisterStartupScript(GetType(), "script", Script);