多次点击提交按钮 [英] Multiple click on submit button

查看:183
本文介绍了多次点击提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在准备消息发送功能.写完消息后,如果我单击提交按钮3到4次,则在那里发布3到4次.为了控制它,我使用了以下代码:

Hi Everyone,

I am preparing a message sending feature. There after writing the message if I click on the submit button for 3 to 4 times, it is posting for 3 to 4 times. To control this I used the following code:

protected void imgbtnSend_Click(object sender, ImageClickEventArgs e)
{
    imgbtnSend.OnClientClick = "this.disabled = true; " + ClientScript.GetPostBackEventReference(new PostBackOptions(imgbtnSend));
    //code for messaging
}



现在,它在我的本地系统中运行良好.但是在服务器中部署后无法正常工作.

我想一次发表一篇文章.

请提出任何建议.



Now it is working fine in my local system. But it is not working after deploying in server.

I want to make it a single post at a time.

Any suggestion please.

推荐答案

尝试以下代码.........

Try Following Code............

protected void Page_Load(object sender, EventArgs e)
    {
        btnsave.Attributes.Add("onclick",      "this.disabled=true;this.value='Processing....';" + ClientScript.GetPostBackEventReference(btnsave, "").ToString());      

}

 protected void btnsave_Click(object sender, EventArgs e)
     {
     }


您可以将其固定为aspx页面.

you can fixed it aspx page.

function ConfirmBooking(imgLoad)
    {
    document.getElementById('imgbtnsubmit').style.display = none;
    document.getElementById(imgLoad).style.display = block;
    return true;
    }

<img id="imgLoad" src="images/Progress.gif" alt="" style="display: none;" runat="server" />
<asp:ImageButton ID="imgbtnsubmit" runat="server" OnClientClick="javascript:return ConfirmBooking('imgLoad');"
    ImageUrl="images/submit.gif" OnClick="imgbtnSend"/>

    protected void imgbtnSend_Click(object sender, ImageClickEventArgs e)
    {
    }


protected void imgbtnSend_Click(object sender, ImageClickEventArgs e)
{

// you better write code to validate whether the message is empty before sending //message and also write code to  clear the message after sending the message.

}


这篇关于多次点击提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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