M
mmorrison93
I'm trying to set up a test asynchronously executing page that will
call a database stored procedure and then simply add text to a Label
control name mylabel However after executing the BeginEventHandler,
the EndEventHandler is not called and I have no idea why any help is
appreciated. My .aspx file is minimal the only thing on the page is my
label.
In my code behind file i have the following:
protected void Page_Load(object sender, System.EventArgs e)
{
PageAsyncTask task = new PageAsyncTask(
new BeginEventHandler(BeginTask),
new EndEventHandler(EndTask),
null,
null);
RegisterAsyncTask(task);
Page.ExecuteRegisteredAsyncTasks();
}
public IAsyncResult BeginTask(object sender, EventArgs e,
AsyncCallback cb, object state)
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionString.
["conn"].ConnectionString))
{
cmd = new SqlCommand("sp_AnheiserBusch_GetWeeks", cn);
cmd.CommandType = CommandType.StoredProcedure;
IAsyncResult ar;
try
{
cn.Open();
ar = cmd.BeginExecuteReader(cb, state);
}
finally
{
cn.Close();
}
return ar;
}
}
public void EndTask(IAsyncResult ar)
{
mylabel.Text = "EndTask";
}
Thanks.
call a database stored procedure and then simply add text to a Label
control name mylabel However after executing the BeginEventHandler,
the EndEventHandler is not called and I have no idea why any help is
appreciated. My .aspx file is minimal the only thing on the page is my
label.
In my code behind file i have the following:
protected void Page_Load(object sender, System.EventArgs e)
{
PageAsyncTask task = new PageAsyncTask(
new BeginEventHandler(BeginTask),
new EndEventHandler(EndTask),
null,
null);
RegisterAsyncTask(task);
Page.ExecuteRegisteredAsyncTasks();
}
public IAsyncResult BeginTask(object sender, EventArgs e,
AsyncCallback cb, object state)
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionString.
["conn"].ConnectionString))
{
cmd = new SqlCommand("sp_AnheiserBusch_GetWeeks", cn);
cmd.CommandType = CommandType.StoredProcedure;
IAsyncResult ar;
try
{
cn.Open();
ar = cmd.BeginExecuteReader(cb, state);
}
finally
{
cn.Close();
}
return ar;
}
}
public void EndTask(IAsyncResult ar)
{
mylabel.Text = "EndTask";
}
Thanks.