我已经在我的 SharePoint 网站上创建了 .aspx 页面并在页面中插入了 HTML 按钮。
示例
<PublishingWebControls:editmodepanel PageDisplayMode="Display" runat="server" SuppressTag="True">
...
<button>Click Me!</button>
...
</PublishingWebControls:editmodepanel>
每次我点击“点击我!”回发发生。这不是我想要的行为,但我找到了一种不引起回发的方法。我将 javascript 代码添加到 onclick 属性 <button onclick='return false;'>Click Me!</button>
我的问题是,为什么回发发生,即使按钮不包含 type="submit"
属性(property)?
我还检查了母版页,其中包含 <form runat="server">
并包装所有内容,也没有 action="page.aspx"
属性(property)。
最佳答案
检查此链接,http://www.w3schools.com/tags/tag_button.asp 页面上有一个注释,说不同的浏览器可以使用不同的按钮默认类型,如果你不自己指定的话。好像您的浏览器使用“提交”。
关于javascript - 为什么任何 html 按钮都会导致 aspx 页面中的回发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17995007/