[英]how to prevent button to trigger a postback on aspx
自从我上次使用JQUERY-UI创建网站以来已经有一段时间了。 我有一个aspx页面,并且我尝试在点击时添加一个弹出模式
但是当我单击该按钮时会触发“提交”,如何防止提交? 它显示弹出窗口2秒钟,然后发生“提交”。
这是HTML代码
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all">
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all">
</fieldset>
</form>
</div>
<div id="users-contain" class="ui-widget">
<h1>Existing Users:</h1>
<table id="users" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>john.doe@example.com</td>
<td>johndoe1</td>
</tr>
</tbody>
</table>
</div>
<button id="create-user">Create new user</button>
您可以阻止提交操作-
$('form').on('submit',function(e){
e.preventDefault();
});
在您要设置弹出窗口的Jquery代码中,最后写入return false ...谢谢
最简单的方法是返回false OnClientClick, <asp:Button OnClientClick="return false;"></button>
。
在按钮中添加type属性, type="button"
。 默认是submit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.