Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem in using Response.BinaryWrite and changing controls

Problem in using Response.BinaryWrite and changing controls

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mahesvs
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • M mahesvs

      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

      D Offline
      D Offline
      DoctorMick
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • D DoctorMick

        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.

        M Offline
        M Offline
        mahesvs
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • M mahesvs

          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

          D Offline
          D Offline
          DoctorMick
          wrote on last edited by
          #4

          You will need to use the client id of the link button in your javascript, something like:

          document.getElementById("<%=LinkButton1.ClientID%>").disabled = false;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups