On a masterpage I have my scriptmanager with enablepartialrendering is true.
On the page I have a usercontrol, on this usercontrol is an update panel with Updatemode is conditional.
It’s about two listboxes that swapped an item from the left listbox to the right listbox by clicking on an imagebutton. (This works fine)
The two imagebuttons are in a div block for the stylesheet.
I use the postbacktrigger for them.
Still the whole page refreshes, what am I doing wrong?
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DoubleListBox.ascx.cs"
Inherits="site.Controls.DoubleListBox" %>
<div class="formfield ff_itemswapper">
<asp:Label ID="Label" runat="server" />
<div class="itemswapper">
<asp:UpdatePanel ID="updatePanelListboxes" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ListBox ID="lsbFrom" runat="server" CssClass="is_current"></asp:ListBox>
<div class="is_transfers" runat="server">
<asp:ImageButton ID="imb_Left" runat="server" CssClass="is_transfer_in" ImageUrl="../Images/gfx/arrow_left.png"
OnClick="imbLeft_Click" CausesValidation="False" />
<asp:ImageButton ID="img_Right" runat="server" CssClass="is_transfer_out" ImageUrl="../Images/gfx/arrow_right.png"
OnClick="imgRight_Click" CausesValidation="False" />
</div>
<asp:ListBox ID="lsbTo" runat="server" CssClass="is_source"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="imb_Left" />
<asp:PostBackTrigger ControlID="img_Right" />
</Triggers>
</asp:UpdatePanel>
</div>
The listbox is registered in the aspx page by
<%@ Register Src="~/Controls/DoubleListBox.ascx" TagName="DoubleListBox" TagPrefix="lsb" %>
And called by:
<lsb:DoubleListBox ID="lsbPractise" runat="server" />
You seem to misunderstand what a
PostBackTriggerdoes.A
PostBackTriggercauses a full page postback, whereas anAsyncPostBackTriggerdoes an AJAX call from within theUpdatePanel. All elements inside theUpdatePanelautomatically callAsyncPostBackTriggers and all elements outside the panel callPostBackTriggers.So, to solve your problem, simply remove your entire
Triggerssection.