In my user control I have the following markup:
<div id="pageEditsView" style="margin-left:540px">
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="PageEditList"/>
</Triggers>
<ContentTemplate>
<asp:HiddenField runat="server" ID="CurrentPageId"/>
<asp:Label runat="server" ID="EditDisplayLabel" Visible="False">Edits tied to this page:</asp:Label>
<br/>
<ul>
<asp:Repeater runat="server" ID="PageEditList" OnItemCommand="PageEditList_ItemCommand">
<ItemTemplate>
<li>
<%# ((PageEdit)Container.DataItem).CachedName %>
(<asp:LinkButton ID="LinkButton1" runat="server" Text="remove" CommandName="remove" CommandArgument="<%# ((PageEdit)Container.DataItem).Id %>" />)
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Whenever I click on the remove link button, it is performing a full page postback instead of just updating this control's panel. My master page has the following setup:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
Other parts of this application (which I inherited, and the old dev who wrote this is no longer around) seems to do partial page updates just fine. Am I doing something wrong?
Try to register the linkbutton as async postback control, the appropriate place is the ItemCreated
event which is triggered on every (async/full) postback:
protected void PageEditList_ItemCreated(Object Sender, RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ScriptManager scriptMan = ScriptManager.GetCurrent(this);
LinkButton btn = e.Item.FindControl("LinkButton1") as LinkButton;
if(btn != null)
{
btn.Click += LinkButton1_Click;
scriptMan.RegisterAsyncPostBackControl(btn);
}
}
}
Add this after ContentTemplate
<Triggers>
<asp:AsyncPostBackTrigger ControlID="PageEditList" EventName="ItemCommand" />
</Triggers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With