Problem in using Response.BinaryWrite and changing controls
-
Hi, I have a button which needs to download the file, simaltaneously it has to enable or disable the linkbutton on a click event. I went for the following code which never works for me.. The problem is there in writing the file in response. Any idea is highly valuable. Thanks in advance.. Given the code below.. ---- LinkButton1.Enabled = false; System.IO.FileStream fs = null; fs = System.IO.File.Open("c://4377.doc", System.IO.FileMode.Open); byte[] btFile = new byte[fs.Length]; fs.Read(btFile, 0, Convert.ToInt32(fs.Length)); fs.Close(); Response.AddHeader("Content-disposition", "attachment; filename=4377.mpp"); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(btFile); Response.End(); ----------- Thanks Maheshkumar
-
Hi, I have a button which needs to download the file, simaltaneously it has to enable or disable the linkbutton on a click event. I went for the following code which never works for me.. The problem is there in writing the file in response. Any idea is highly valuable. Thanks in advance.. Given the code below.. ---- LinkButton1.Enabled = false; System.IO.FileStream fs = null; fs = System.IO.File.Open("c://4377.doc", System.IO.FileMode.Open); byte[] btFile = new byte[fs.Length]; fs.Read(btFile, 0, Convert.ToInt32(fs.Length)); fs.Close(); Response.AddHeader("Content-disposition", "attachment; filename=4377.mpp"); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(btFile); Response.End(); ----------- Thanks Maheshkumar
Are you getting an error? If you want the link button to be disabled once you've clicked it and the page is processing you'll have to use javascript to disable it.
-
Are you getting an error? If you want the link button to be disabled once you've clicked it and the page is processing you'll have to use javascript to disable it.
-
Used the javascript option but there is no use. It remains the same. I called the javascript function in the clientclick event of the button and gave the following line. document.getElementById("LinkButton1").disabled=false; Thanks Maheshkumar B
You will need to use the client id of the link button in your javascript, something like:
document.getElementById("<%=LinkButton1.ClientID%>").disabled = false;