DarkWorlds
Technical User
Ok I was not able to get anything in the two other threads I started started. So finely I sat down to do something VERY simple. But it seems its broke.
What I want to do is disable the button whuile a query runs to get the download. Well it does that just fine. Excepts it never un-disables the button when done. Please help me out with this. Here is the code.
Bankend
HTML
What I want to do is disable the button whuile a query runs to get the download. Well it does that just fine. Excepts it never un-disables the button when done. Please help me out with this. Here is the code.
Bankend
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.IO;
namespace Tester
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnBack;
private void Page_Load(object sender, System.EventArgs e)
{
btnBack.Attributes.Add("onclick", GetPostBackEventReference(btnBack) + ";this.value='Please wait...';this.disabled = true;");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnBack_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("JohnsTable");
ds.Tables.Add(dt);
DataColumn dc1 = new DataColumn("Name");
DataColumn dc2 = new DataColumn("Valve");
DataColumn dc3 = new DataColumn("Time");
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
DataRow dr = dt.NewRow();
dr["Name"] = "Jim";
dr["Valve"] = "34";
dr["Time"] = "12:00";
dt.Rows.Add(dr);
ExcelConvert(ds, Response);
}
public static void ExcelConvert(DataSet ds, HttpResponse response)
{
string startDate = System.DateTime.Today.ToShortDateString();
string endDate = System.DateTime.Today.AddDays(7).ToShortDateString();
response.Clear();
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htmlWrite);
Thread.Sleep(3000);
response.Write(stringWrite.ToString());
response.End();
}
}
}
HTML
Code:
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="Tester.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5">[/URL]
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="btnBack" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 56px" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</HTML>