本文介绍了避免在按钮单击事件中在asp.net中发回邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想避免在按钮单击事件上回发.在这里,我的要求是,第一次我的页面加载时带有一些初始值,这些初始值是从javascript设置的.&我想在按钮单击事件触发后保留这些值.
你能尽快帮我吗?.
谢谢..
Hi,
I want to avoid postback on button click event.Here,my requirement is that, first time my page load with some initial values which are set it as from javascript.& I want to preserve these values after button click event fires.
Can you help me asap..
Thanks..
推荐答案
<script type = "text/javascript">
function validate() {
var txt = document.getElementById("<%=Textbox1.ClientID%>").value;
if (txt == "") {
alert("Please enter your name in the textbox before proceeding.");
}
else {
window.location = "default.aspx";
}
}
</script>
并在按钮中:
and in the button:
<asp:button id="Button1" runat="server" text="Proceed" onclientclick="validate(); return false" xmlns:asp="#unknown" />
函数调用后返回false阻止回发.
the return false after the function call prevents the postback.
这篇关于避免在按钮单击事件中在asp.net中发回邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!