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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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>
回答2:
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>
.