Jan 10, 2016, 3:31 AM
Codebehind event called from Task
Hello,
I have a this TaskManager with two tasks in a webpage and I assign to each task a different user-configurable interval on Page-OnLoad event:
Why my code is causing this behaviuor to the browser?
Thanks
Regards
Alex
I have a this TaskManager with two tasks in a webpage and I assign to each task a different user-configurable interval on Page-OnLoad event:
<ext:TaskManager ID="TaskManager1" runat="server">
<Tasks>
<ext:Task TaskID="taskEstadoParqueo" Interval="5000" AutoRun="true">
<DirectEvents>
<Update OnEvent="ActualizaEstadoParqueo" />
</DirectEvents>
</ext:Task>
<ext:Task TaskID="taskAlerta" Interval="5000" AutoRun="true">
<DirectEvents>
<Update OnEvent="ActualizaEstadoAlerta" />
</DirectEvents>
</ext:Task>
</Tasks>
</ext:TaskManager>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TaskManager1.Tasks[0].Interval = SegundosParqueoPublico;
TaskManager1.Tasks[1].Interval = SegundosAlertasRapidas;
}
}
protected void ActualizaEstadoParqueo(object sender, DirectEventArgs e)
{
string sql = "SELECT Configuracion, Valor FROM CONFIGURACION_GLOBAL WHERE Configuracion = 'pp-espacios' OR Configuracion = 'pp-ocupado'";
DataTable dt = AccesoDatos.SqlServer.SQL_SELECT(sql);
int espacios = 0, ocupados = 0;
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
if (dr["Configuracion"].ToString().Equals("pp-espacios"))
espacios = Convert.ToInt32(dr["Valor"]);
else if (dr["Configuracion"].ToString().Equals("pp-ocupado"))
ocupados = Convert.ToInt32(dr["Valor"]);
}
}
this.lblParqueosD.Text = (espacios - ocupados).ToString();
this.lblParqueosU.Text = ocupados.ToString();
this.lblAlerta.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
}
protected void ActualizaEstadoAlerta(object sender, DirectEventArgs e)
{
this.lblAlerta2.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
}
DirectEvents are getting called as expected, but I've oticed this behaviour: In my code, every time a codebehind event is called, the browser's reload button changes as if it was clicked (but page is not reloaded). When I run your Task example, browser's reload button doesn't change.Why my code is causing this behaviuor to the browser?
Thanks
Regards
Alex