2
I would like to know how I can transfer items between two Listbox, I want that when the user of two clicks on an item the same is already transferred from one listbox to the other.
I did not find any event in my Asp-Listbox double click.
In the link below there is an example of Telerik control but it is paid, I need some solution as Javascript
http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/transfer/defaultcs.aspx
I managed to find a solution to my problem, I do not know if it is the best practice but it worked the way I needed, The java script calls the event button that does the job of changing the items without causing problem at the time of recording.
Button Code
<asp:ImageButton ID="imgbDireita" ImageUrl="~/Imagens/Icones/SetaDireita.png" runat="server" OnClick="imgbDireita_Click" />
<asp:ImageButton ID="imgbEsquerda" ImageUrl="~/Imagens/Icones/SetaEsquerda.png" runat="server" OnClick="imgbEsquerda_Click" />
Button Event
protected void imgbDireita_Click(object sender, ImageClickEventArgs e)
{
if (lstCompartimentosAtivos.SelectedIndex >= 0)
{
lstCompartimentosInativos.Items.Add(lstCompartimentosAtivos.Items[lstCompartimentosAtivos.SelectedIndex]);
lstCompartimentosAtivos.Items.RemoveAt(lstCompartimentosAtivos.SelectedIndex);
lstCompartimentosInativos.SelectedIndex = -1;
lstCompartimentosAtivos.SelectedIndex = -1;
}
}
protected void imgbEsquerda_Click(object sender, ImageClickEventArgs e)
{
if (lstCompartimentosInativos.SelectedIndex >= 0)
{
lstCompartimentosAtivos.Items.Add(lstCompartimentosInativos.Items[lstCompartimentosInativos.SelectedIndex]);
lstCompartimentosInativos.Items.RemoveAt(lstCompartimentosInativos.SelectedIndex);
lstCompartimentosInativos.SelectedIndex = -1;
lstCompartimentosAtivos.SelectedIndex = -1;
}
}
Java Script
jQuery(document).ready(function () {
function ativoParaInativo() {
var imgb = document.getElementById('<%=imgbDireita.ClientID%>');
imgb.click();
}
function inativoParaAtivo() {
var imgb = document.getElementById('<%=imgbEsquerda.ClientID%>');
imgb.click();
}
$('#cphConteudo_tabImovel_tabCompartimentos_lstCompartimentosAtivos').dblclick(function () {
ativoParaInativo();
});
$('#cphConteudo_tabImovel_tabCompartimentos_lstCompartimentosInativos').dblclick(function () {
inativoParaAtivo();
});
});
Look if here can help you. https://api.jquery.com/dblclick/
– Marconi