Good afternoon.
I have an asp.net webform application, and am having the following problem.
In a certain part of the system, the customer has two buttons to navigate between editions of a magazine, going to the next and previous. This works correctly, but sometimes the client clicks multiple times simultaneously until they get to the edition they want, instead of waiting to load one by one.
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 queries and multiple indexing.
I wanted to know if you have a way to prevent this from happening. From the client you can click several times fast until you get the edition you want, and then call the button event.
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.