During my testing, I encountered an issue with buttons inside a repeater within an update panel. When adding asyncpostback triggers for the buttons using <Trigger></Trigger>
, an error is generated indicating that the button could not be found.
In my scenario, I have two linkbuttons inside the repeater and I added JavaScript code for
OnClick="__doPostback(linkbutton1, '');"
, which successfully executes without causing a full postback. The button functions correctly and displays the desired message.
The functionality works smoothly without experiencing any FullPostBack problems.
<asp:LinkButton runat="server" ID="linkbutton" OnClientClick="__doPostback(linkbutton1.UniqueID, '');" />
I prefer to use a function instead of directly inserting code into the OnClick attribute, but this has caused some issues to arise.
For example:
function postback(){
__doPostback(linkbutton1.UniqueID, '');
}
ASP.NET Code:
<asp:UpdatePanel ID="update_buttons" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Repeater ID="repeaterb" runat="server">
<ItemTemplate>
<asp:LinkButton runat="server" ID="linkbutton" OnClientClick="return postback();" />
<asp:LinkButton runat="server" ID="linkbutton1" OnClick="linkbutton1_Click"/>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Code Behind:
Page.ClientScript.RegisterStartupScript(this.GetType(), "postback", "postback()", true);