按钮的onclick没有内部形状工作 [英] Button Onclick does not work inside form
问题描述
好日子
我使用的是ASP.NET Web窗体在那里我有包裹的形式标记内以下按钮:
I am using an ASP.NET webform where I have wrapped the following button inside the form tags:
<form runat="server">
<button class="btn btn-primary" onclick="window.location='http://google.co.za';">Login</button>
</form>
问题:问题是,在按钮上点击的时候,它只是引导到当前页面......不会重定向。然而,当我删除表单标签,按钮的工作原理。如果我离开表单标签和我使用一个锚点标签重新定位,它的工作原理以及...它只是是给我的问题的按钮。
ISSUE: The problem is that when clicking on the button, it just directs to the current page...does not redirect. However, when I remove the form tags, the button works. If I leave the form tags and I use an anchor tag to relocate, it works as well...It is just the button that is giving me issues.
这是为什么?
我使用Twitter的引导,以及(额外的信息..)
I am using Twitter bootstrap as well(extra info..)
感谢您
推荐答案
添加键入=按钮
属性的按钮
标记。没有它键设置为提交
。
Add type="button"
attribute to your button
tag. Without it button works as submit
.
这篇关于按钮的onclick没有内部形状工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!