我有一个服务器段运行的button
代码如下
private void btnSendPhoneMessage_Click(object sender, System.EventArgs e)
{
btnSendPhoneMessage.Enabled=false;
sendmessges();
Response.Redirect("/JsEducation/MyCommunity/sendMessageSuccess.aspx");
}
我想在点击以后就执行btnSendPhoneMessage.Enabled=false;
然后在执行sendmessges();
Response.Redirect("/JsEducation/MyCommunity/sendMessageSuccess.aspx");
我估计是在客户端设置的,要具体怎么设置呢?

解决方案 »

  1.   

    你不用 Response.Redirect("/JsEducation/MyCommunity/sendMessageSuccess.aspx");
    这段啊,反正它都要放回原来的页面的。这样的话,你的butto你就可以是enable=flase的了。
      

  2.   

    在点击后执行sendmessges();需要一定的时间,所以用户可能再次点击,我是要解决这样的问题
      

  3.   

    再次点击就可能执行两次sendmessges();
      

  4.   

    就像csdn的button的按钮的效果一样
    只是我的是<asp:button runat="server"
      

  5.   

    那把它写到Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
    btnSendPhoneMessage.Enabled=false;
        End Sub
    这个过程试试吧
       
      

  6.   

    那就写个事件在客户端了
    在pageload里加一个buttonname.Attributes.Add("onClick","javascript:document.buttonname.disabled=\"disabled\";");
      

  7.   

    在事件触发中加一个Enabled=False
      

  8.   

    to xifan930()
    那样做是不行的,我开始就是那么做
    我觉得应该在客户端解决,有什么办法嘛?
      

  9.   

    那能不能告诉我一下直接用javascipt怎么控制
      

  10.   

    用以下办法
    this.Button1.Attributes.Add("onclick","this.disabled=true;");
      

  11.   

    to  hchxxzx
    为什么我设置在page_load里面然后点击button他不会执行事件呢?
    怎么样才能解决呢
      

  12.   

    能不能在sendmessges()里面写
    btnSendPhoneMessage.Enabled=false;
      

  13.   

    然后点击button他不会执行事件呢?
    --------------
    是不执行什么事件?服务端的?客户端的?
      

  14.   

    private void btnSendPhoneMessage_Click(object sender, System.EventArgs e)
    {

    sendmessges();
    Response.Redirect("/JsEducation/MyCommunity/sendMessageSuccess.aspx");
    }
    还要点击执行这个
      

  15.   

    基本思路就是 hchxxzx 写到的!!
    我曾用此种方法在客户端执行一些(判断事件),现在的问题只是把事件改成修改属性,
    这应该是一样道理的!!回头写个程序测一下!
    你的邮箱??
    测试成功后发给你!
      

  16.   

    测试了一下,发觉真的是不执行.
    原因可能是,将按钮置为不可用,则在页面提交之后,服务端无法检测到该按钮,则无法顺利执行事件.
    现可简单改为如下:
    先在页面头部中写一个脚本变量:
    <script>var count=0;</script>
    然后在后台如下写进行测试
    this.Button1.Attributes.Add("onclick","count++;if(count!=1){alert('第2次提交,不执行');return(false);}else{alert('执行');}");
    测试完成之后改如下:
    this.Button1.Attributes.Add("onclick","count++;if(count!=1){return(false);}");