3
Good afternoon.
I have an Asp.net webform application, and am having the following problem.
In a certain part of the system, the client has two buttons to navigate between the issues of a magazine, going to previous and next. This works correctly, but sometimes the client clicks several times simultaneously until he arrives at the edition he wants, instead of waiting to load one by one (just).
However, when it does this, every click it gives is called the event contained in the button click, and it is a time consuming event, with database query and various indexes.
I was wondering if you had a way to stop that from happening. From the customer to be able to click several times fast until you get to the edit you want, and only then call the button event.
the button:
<asp:Button ID="btnProximaEdicao" runat="server" onclick="btnProximaEdicao_Click" OnClientClick="return mudarEdicao('proxima');" Text="Próxima" Height="34px"/>
JS:
function mudarEdicao(acao) {
if (!verificarColunas())
return false;
else {
var filtro = $('select[name$="LstFiltros"]').find('option');
$.each(filtro, function (key, value) {
var coluna = $(value).val();
if (coluna.indexOf('Edição') >= 0) {
var edicao = coluna.substr(7);
var proxEdicao;
if (acao == "anterior")
proxEdicao = parseInt(edicao) - 1;
else
proxEdicao = parseInt(edicao) + 1;
$('select[name$="LstFiltros"]').find('option[value^="Edição"]').val("Edição:" + proxEdicao);
$('select[name$="LstFiltros"]').find('option[value^="Edição"]').text("Edição:" + proxEdicao);
}
});
}
return true;
}
Codebehind:
protected void btnProximaEdicao_Click(object sender, EventArgs e)
{
for (var i = 0; i < LstFiltros.Items.Count; i++)
{
if (LstFiltros.Items[i].Text.Contains("Edição:"))
{
string edicao = LstFiltros.Items[i].Text.Substring(7);
int proxEdicao = Convert.ToInt32(edicao) + 1;
LstFiltros.Items.Remove(LstFiltros.Items[i].Text);
((List<DocumentoCamposDTO>)this.getParameter("CAMPOS_PESQUISA")).RemoveAll(p => p.TipoIndexacaoCampo.GUID.Equals(Functions.ConvertToGuid(LstGuidCampos.Items[i].Text)));
LstFiltros.Items.Add("Edição:" + proxEdicao);
InsereFiltrosPesquisa();
}
}
preencherGridPesquisa();
}
thank you very much.
Using an Updatepanel to update the content?
– Tobias Mesquita