Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 09, 2012 04:48 AM by hsjpy
0 Points
5 Posts
Apr 06, 2012 07:48 AM|LINK
I have HTML code like this
<asp:LinkButton ID="AddButton" runat="server" OnClick="AddPatientBtn_Click"> <span class="Normal">Add</span> </asp:LinkButton>
I find if we click 'Add' several time, and it will add several patient records. I change the code like this
i use js like:
button.disabled = true or button.disabled = 'disabled'
but it still can add several patient records
what should i do ?
Star
7625 Points
1454 Posts
Apr 06, 2012 08:02 AM|LINK
in linkbutton click event, make it visible false
protected void AddButton_Click(object sender, EventArgs e) { AddButton.Visible = false; }
Participant
1513 Points
292 Posts
Apr 06, 2012 08:06 AM|LINK
Hi,
Check out following links:
http://stackoverflow.com/questions/6284861/asp-net-prevent-double-clicking
http://www.codeproject.com/Questions/114164/Prevent-user-from-clicking-submit-multiple-times
http://stackoverflow.com/questions/926816/how-to-prevent-multiple-form-submit-from-client-side
http://forums.codeguru.com/showthread.php?t=480279
Though, the problem of duplicate entry in the database can be handled by enforcing some unique key in the table.
Thank you
Apr 06, 2012 09:09 AM|LINK
when i click add button, it still there.
i think when the page is send to server ,it will display the 'Add' link
because the new page has not be send back from server where AddButton.Visible is false.
Apr 06, 2012 09:13 AM|LINK
santosh.jagdale in linkbutton click event, make it visible false protected void AddButton_Click(object sender, EventArgs e) { AddButton.Visible = false; }
All-Star
43050 Points
7036 Posts
MVP
Apr 06, 2012 12:54 PM|LINK
hsjpy button.disabled = true or button.disabled = 'disabled'
Hello,
I don't think you can do like this. Use below syntax
document.getElementById('<%=AddButton.ClientID%>').disabled = true;
Please 'Mark as Answer' if this post helps you.
Member
62 Points
11 Posts
Apr 06, 2012 12:56 PM|LINK
on click of button write following code
AddButton.Enabled=false Happy Programming
Apr 09, 2012 04:48 AM|LINK
Thanks for all of you!
I find that LinkButton may not have the disable attribute, it is a <a> in html page.
so I use another solution
<asp:LinkButton ID="AddButton" runat="server" OnClick="AddPatientBtn_Click" OnClientClick="return DisableButton()"> <span class="Normal">Add</span> </asp:LinkButton>
js:
var pending = false; function DisableButton() { if (pending) { alert("The new patient is being created. Please wait..."); return false; } else { if (Page_ClientValidate("")) pending = true; return true; } }
hsjpy
0 Points
5 Posts
how to disable a linkbutton to prevent submit several times
Apr 06, 2012 07:48 AM|LINK
I have HTML code like this
I find if we click 'Add' several time, and it will add several patient records. I change the code like this
i use js like:
but it still can add several patient records
what should i do ?
santosh.jagd...
Star
7625 Points
1454 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 08:02 AM|LINK
in linkbutton click event, make it visible false
protected void AddButton_Click(object sender, EventArgs e) { AddButton.Visible = false; }MCP
shatru
Participant
1513 Points
292 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 08:06 AM|LINK
Hi,
Check out following links:
http://stackoverflow.com/questions/6284861/asp-net-prevent-double-clicking
http://www.codeproject.com/Questions/114164/Prevent-user-from-clicking-submit-multiple-times
http://stackoverflow.com/questions/926816/how-to-prevent-multiple-form-submit-from-client-side
http://forums.codeguru.com/showthread.php?t=480279
Though, the problem of duplicate entry in the database can be handled by enforcing some unique key in the table.
Thank you
Regards
Ajatshatru
Dragons Lab
hsjpy
0 Points
5 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 09:09 AM|LINK
when i click add button, it still there.
i think when the page is send to server ,it will display the 'Add' link
because the new page has not be send back from server where AddButton.Visible is false.
hsjpy
0 Points
5 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 09:13 AM|LINK
when i click add button, it still there.
i think when the page is send to server ,it will display the 'Add' link
because the new page has not be send back from server where AddButton.Visible is false.
</div>Ruchira
All-Star
43050 Points
7036 Posts
MVP
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 12:54 PM|LINK
Hello,
I don't think you can do like this. Use below syntax
document.getElementById('<%=AddButton.ClientID%>').disabled = true;
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.Shailen0287
Member
62 Points
11 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 06, 2012 12:56 PM|LINK
on click of button write following code
hsjpy
0 Points
5 Posts
Re: how to disable a linkbutton to prevent submit several times
Apr 09, 2012 04:48 AM|LINK
Thanks for all of you!
I find that LinkButton may not have the disable attribute, it is a <a> in html page.
so I use another solution
js:
var pending = false; function DisableButton() { if (pending) { alert("The new patient is being created. Please wait..."); return false; } else { if (Page_ClientValidate("")) pending = true; return true; } }