我有一个服务器段运行的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");
我估计是在客户端设置的,要具体怎么设置呢?
代码如下
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");
我估计是在客户端设置的,要具体怎么设置呢?
这段啊,反正它都要放回原来的页面的。这样的话,你的butto你就可以是enable=flase的了。
只是我的是<asp:button runat="server"
btnSendPhoneMessage.Enabled=false;
End Sub
这个过程试试吧
在pageload里加一个buttonname.Attributes.Add("onClick","javascript:document.buttonname.disabled=\"disabled\";");
那样做是不行的,我开始就是那么做
我觉得应该在客户端解决,有什么办法嘛?
this.Button1.Attributes.Add("onclick","this.disabled=true;");
为什么我设置在page_load里面然后点击button他不会执行事件呢?
怎么样才能解决呢
btnSendPhoneMessage.Enabled=false;
--------------
是不执行什么事件?服务端的?客户端的?
{
sendmessges();
Response.Redirect("/JsEducation/MyCommunity/sendMessageSuccess.aspx");
}
还要点击执行这个
我曾用此种方法在客户端执行一些(判断事件),现在的问题只是把事件改成修改属性,
这应该是一样道理的!!回头写个程序测一下!
你的邮箱??
测试成功后发给你!
原因可能是,将按钮置为不可用,则在页面提交之后,服务端无法检测到该按钮,则无法顺利执行事件.
现可简单改为如下:
先在页面头部中写一个脚本变量:
<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);}");