具有不同按钮类型的 Asp 按钮 [英] Asp button with different button type

查看:24
本文介绍了具有不同按钮类型的 Asp 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可能有一个不使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆