具有不同按钮类型的 Asp 按钮 [英] Asp button with different button type
问题描述
是否可能有一个不使用 type="submit"
标记呈现的 asp 按钮.我不希望按钮提交表单,所以我想把它作为 type="button"
代替.也许更好的表达我的问题的方法是:如何防止 asp 按钮提交?
Is it possible to have an asp button that isn't rendered with a type="submit"
tag. I don't want the button to submit the form, so I'd like to have it as type="button"
instead. Perhaps a better way to phrase my question would be: How do I prevent an asp button from submitting?
推荐答案
如果你不想提交按钮,你需要一个按钮吗?毕竟,它在回发到服务器之前什么都不做.您也可以只使用 <input type="button"
.
If you don't want the button to submit, do you need a button at all ? After all, it doesn't do anything before it posts back to the server. You can might as well just use an <input type="button"
.
话虽如此,您可以使用 javascript 来防止回发:
That being said, you can use javascript to prevent a postback:
<asp:Button runat="server" OnClientClick="return false;" />
这篇关于具有不同按钮类型的 Asp 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!