You are setting btnMoveUp and btnMoveDown as AsyncPostBackControls. But that makes them AsyncPostBackControls for the entire page, so clicking them updates both updatepanels.
Remove the myscriptmanager.RegisterAsyncPostBackControl(...) lines.
Thanks for reply.
I had already tried your suggestions.
My purpose is to move items from left to right listbox .In centre to them are buttons to move items.which works with both updatepanel flicker like a refresh.But i have move up and down buttons for right listbox but i can not place these 2 buttons in second update panel and causes flicker with asynchronous trigger as you suggested.
Why there is a flicker with listbox control.
Any other suggestions are welcome.
Hi,
Thank you for your post!
I think you need one more Updatepanle! Do it like this:
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btnMoveUp_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Item As New ListItem
Dim PrevIndex As Integer
'Move sites order of preference in up direction
If lstSelectedSites.GetSelectedIndices.Length = 1 Then
If lstSelectedSites.SelectedIndex <> -1 ThenItem.Value = lstSelectedSites.SelectedValue
Item.Text = lstSelectedSites.SelectedItem.ToString
PrevIndex = CInt(lstSelectedSites.SelectedIndex) - 1
If PrevIndex = -1 Then
Exit Sub
End If
lstSelectedSites.Items.Remove(lstSelectedSites.SelectedItem)
lstSelectedSites.Items.Insert(PrevIndex, Item.Text)
lstSelectedSites.Items.Item(PrevIndex).Value = Item.Value
lstSelectedSites.SelectedIndex = PrevIndexEnd If
End If
End SubProtected Sub btnMoveDown_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Item As New ListItem
Dim NextIndex As Integer
'Move sites order of preference in up direction
If lstSelectedSites.GetSelectedIndices.Length = 1 Then
If lstSelectedSites.SelectedIndex <> -1 ThenItem.Value = lstSelectedSites.SelectedValue
Item.Text = lstSelectedSites.SelectedItem.ToString
NextIndex = CInt(lstSelectedSites.SelectedIndex) + 1
If NextIndex = lstSelectedSites.Items.Count Then
Exit Sub
End If
lstSelectedSites.Items.Remove(lstSelectedSites.SelectedItem)
lstSelectedSites.Items.Insert(NextIndex, Item.Text)
lstSelectedSites.Items.Item(NextIndex).Value = Item.Value
lstSelectedSites.SelectedIndex = NextIndexEnd If
End If
End SubProtected Sub btnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Item As New ListItem
Dim j As Integer = lstAllSites.GetSelectedIndices().Length
'Move sites order of preference in up direction
If j > 0 Then
Dim i As Integer
i = 0
Do While (i < j)
lstSelectedSites.Items.Insert(lstSelectedSites.Items.Count, lstAllSites.Items.Item(lstAllSites.GetSelectedIndices(i)))
lstAllSites.Items.Remove(lstAllSites.Items.Item(lstAllSites.GetSelectedIndices(i)))
j -= 1
Loop
End If
End SubProtected Sub btnUnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Item As New ListItem
Dim j As Integer = lstSelectedSites.GetSelectedIndices().Length
'Move sites order of preference in up direction
If j > 0 Then
Dim i As Integer
i = 0
Do While (i < j)
lstAllSites.Items.Insert(lstAllSites.Items.Count, lstSelectedSites.Items.Item(lstSelectedSites.GetSelectedIndices(i)))
lstSelectedSites.Items.Remove(lstSelectedSites.Items.Item(lstSelectedSites.GetSelectedIndices(i)))
j -= 1
Loop
End If
End Sub
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"UpdateMode="Conditional"
ChildrenAsTriggers="False">
<ContentTemplate>
<table style="width: 100%;">
<tr>
<td>
<asp:UpdatePanelUpdateMode="Conditional" ID="UPanellstAllSites" runat="server">
<ContentTemplate>
<asp:ListBox BorderStyle="None" BackColor="white" ID="lstAllSites" runat="server"
Height="251px" Width="258px" Style="border: none;" SelectionMode="Multiple">
<asp:ListItem Value="1" Text="1" />
<asp:ListItem Value="2" Text="2" />
<asp:ListItem Value="3" Text="3" />
<asp:ListItem Value="4" Text="4" />
<asp:ListItem Value="5" Text="5" />
<asp:ListItem Value="6" Text="6" />
<asp:ListItem Value="7" Text="7" />
<asp:ListItem Value="8" Text="8" />
<asp:ListItem Value="9" Text="9" />
<asp:ListItem Value="10" Text="10" />
</asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Button ID="btnSelect" runat="server" Text="Select" OnClick="btnSelect_Click" />
<asp:Button ID="btnMoveUp" runat="server" Text="MoveUp" OnClick="btnMoveUp_Click" />
<asp:Button ID="btnMoveDown" runat="server" Text="MoveDown" OnClick="btnMoveDown_Click" />
<asp:Button ID="btnUnSelect" runat="server" Text="UnSelect" OnClick="btnUnSelect_Click" />
</td>
<td>
<asp:UpdatePanelUpdateMode="Conditional" ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:ListBox BorderStyle="None" ID="lstSelectedSites" runat="server" Height="291px"
Width="258px" Style="background-color: #c6c6ce; border: none; text-decoration: none;
text-align: center;" SelectionMode="Multiple"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnMoveDown" />
<asp:AsyncPostBackTrigger ControlID="btnMoveUp" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSelect" />
<asp:AsyncPostBackTrigger ControlID="btnUnSelect" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
This is a full sample for you:)
If you have further questions,let me know!
Best Regards,
Thank you for answer.
It seems code should work as you have given but in my case it is not working. Even simple select html causes flicker while addition of items using javascript.
I have surfed for this problem, as they suggest setting rows instead of height of select box solved problem but not mine.
Please somebody suggest actual select control problem.
No comments:
Post a Comment