Reputation: 131
Buttons inside UpdatePanels are automatically registered as triggers for that UpdatePanel. Is there a way to make the UpdatePanel ignore one of it's inside buttons? That is, to make it so that clicking this button does NOT trigger any sort of postback?
Upvotes: 3
Views: 4801
Reputation: 446
You can set UpdateMode='Conditional'
then set the which buttons you want to trigger a post-back in the <Triggers>
tag. Something like this:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="button1" />
</Triggers>
<ContentTemplate>
...
<asp:Button ID="button1" runat="server" Text="Click Me" />
</ContentTemplate>
</asp:UpdatePanel>
Upvotes: 4
Reputation: 7272
That depends on the use for that button. If the button is to call a codebehind method, then a postback is unavoidable as far as I know.
If you'd like your button to only perform a clientside action, then a plain <input type='button'>
would do better than a <asp:button>
.
Upvotes: 1