避免在按钮单击事件中在asp.net中发回邮件 [英] Avoid postback in asp.net on button click event

查看:56
本文介绍了避免在按钮单击事件中在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..

推荐答案



如果我理解您在说什么,那么您就失去了价值,因为它们不在视图状态中.您有两种选择,要么进行回发并从表单中获取这些值(您刚刚发布的值:Request.Form []),否则可以放置href并将其称为js函数.

希望对您有所帮助.
Hi,

If I understand what you''re saying, you''re loosing your values because they''re not in the viewstate. You have two choices, either you do a postback and get those values from your form (the one you just posted: Request.Form[]) otherwise you can put an href and make it call a js function.

Hope it helps.


您好,ra rajendra @ patil55,

如果您想验证表单或此处的某些内容是我想分享的内容,希望对您有所帮助.

在页面顶部:
Hi ran rajendra@patil55,

If you mean like validating a form or something here is something i would like to share, hope this helps.

in the head of your page:
<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中发回邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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