Hi
i have 2 linkbuttons. one which i will be using for downloading file and uploading after editing the downloading the file from db.
I want to disable link button after download untill another linkbutton is used for uploading.
Linkbutton doesn't seem to disable.
I want to disable download button while download and enable it after upload.
Please Help.
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connString"].ConnectionString);
DisableLinkButton(btndown);
string filename, contentType;
txtDownload.Text = tvBookContent.SelectedNode.Value;
txtchap.Text= tvBookContent.SelectedNode.Text.ToString();
if(txtchap.Text=="Installation of ACS 235 V UHF-1 SYSTEM" || txtchap.Text== "Installation of ACS 235-LH V UHF 1 TRANSCEIVER" || txtchap.Text== "Installation of V UHF-1 ANTENNA 12-200")
{
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
string[] filePaths = Directory.GetFiles(Server.MapPath("~/File/"));
SqlCommand cmd = new SqlCommand("select tbn.vcFilePath,tbn.Rawdata_img,tbn.Rawdata_tbl_xml,tbn.FileName,tbn.Rawfilename_img,tbn.Rawfilename_tbl from tblBookNodes_IPC tbn inner join tblModule tbm on tbn.iModuleId=tbm.iModuleId where tbm.vcModuleTitle='" + txtDownload.Text.ToString() + "'", conn);
conn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
byte[] bytes = (byte[])dr["vcFilePath"];
byte[] bytes_img = (byte[])dr["Rawdata_img"];
byte[] bytes_tbl = (byte[])dr["Rawdata_tbl_xml"];
string flname = dr["FileName"].ToString();
string filename_img = dr["Rawfilename_img"].ToString();
string filename_tbl = dr["Rawfilename_tbl"].ToString();
zip.AddEntry(flname, bytes);
zip.AddEntry(filename_img, bytes_img);
zip.AddEntry(filename_tbl, bytes_tbl);
}
}
conn.Close();
Response.Clear();
Response.BufferOutput = false;
string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
zip.Save(Response.OutputStream);
Response.End();
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Download Sucessfull');", true);
}
}
else
{
SqlCommand cmd1 = new SqlCommand("select tbn.Rawdata,tbn.Rawfilename from tblBookNodes_AMM tbn inner join tblModule tbm on tbn.iModuleId=tbm.iModuleId where tbm.iModuleId='" + txtDownload.Text.ToString() + "'", conn);
conn.Open();
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
byte[] bytes = (byte[])dr["Rawdata"];
contentType = ".xml";
filename = dr["Rawfilename"].ToString();
conn.Close();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
Response.Write(" < script > alert('Download successfully') </ script > ");
}
}
public static void DisableLinkButton(LinkButton btndown)
{
btndown.Attributes.Remove("href");
btndown.Attributes.CssStyle[HtmlTextWriterStyle.Color] = "gray";
btndown.Attributes.CssStyle[HtmlTextWriterStyle.Cursor] = "default";
if (btndown.Enabled != false)
{
btndown.Enabled = false;
}
if (btndown.OnClientClick != null)
{
btndown.OnClientClick = null;
}
}
Thanks