I made disable button on javascript button click and it works in most of cases to prevent double click,but in some cases it does not work so I want to prevent double click also from server side.
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
hfid.value="0";
}
}
protected void frmSubmit_Click(object sender, EventArgs e)
{
if(Convert.ToInt32(hfid.value) == 0)
{
// Code of insert
// then I set hfid.value with newly created id
}
}
<asp:Button ID="frmSubmitInsert" runat="server" OnClick="frmSubmit_Click" OnClientClick="GRVMasterAddButton_Click(this)" Text="Add"
Width="100px" Visible="false" ValidationGroup="masterGrp" />
function GRVMasterAddButton_Click(btn)
{
if (window.Page_ClientValidate('masterGrp'))
{
document.getElementById(btn.id).disabled = true;
__doPostBack(btn.id, '');
}
}
In double click scenario,two times round trip is generated.In First round trip it is ok,but in second round trip though I am setting hfid.value with newly inserted id, it shows me 0 and again duplicate record is generated.