Hello all i have a asp code as
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="please enter any character" ForeColor="#ff3300"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
and i want to stop the user for clicking same button multiple times during page postbacks
so the code written as
static int clicked = 0;
protected void Page_Load(object sender, EventArgs e)
{
clicked = 0;
string strProcessScript = "this.value='Processing...';this.disabled=true;";
Button1.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(Button1, "").ToString());
}
protected void Button1_Click(object sender, EventArgs e)
{
++clicked;
Label1.Text = clicked.ToString();
}
it works fine..but the validation does not work.. and if we comment the lines in page load i.e.
string strProcessScript = "this.value='Processing...';this.disabled=true;";
Button1.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(Button1, "").ToString());
then the validation works, but then user can click button multiple times..
how i can achive both