Hi,
anyone know how to write a single-cilick button? [after click button
is being disabled while the method is executing]
I use this:
<asp:button id="ButtonAdd" runat="server" text="Anuluj"
onclick="Click_ButtonAdd" />
if ( !isPostBack){
ButtonAdd.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(ButtonAdd, "") +
";this.value='Processing Credit Card Payment...';this.disabled =
true;");
}
and I have with this a big problem.
For time to time this method is executing 2 times. I dont know why.
Instend of add 1 record to database it add 2 records.<laziers@.gmail.com> wrote in message
news:f847d30e-4bf7-4cf8-8ec1-8b206006c062@.o77g2000hsf.googlegroups.com...
> anyone know how to write a single-cilick button? [after click button
> is being disabled while the method is executing]
<asp:Button ID="ButtonAdd" runat="server" Text="Anuluj"
OnClick="Click_ButtonAdd"
OnClientClick="this.value='Processing Credit Card
Payment...';this.disabled=true;" />
Mark Rae
ASP.NET MVP
http://www.markrae.net
> <asp:Button ID="ButtonAdd" runat="server" Text="Anuluj"
> OnClick="Click_ButtonAdd"
> OnClientClick="this.value='Processing Credit Card
> Payment...';this.disabled=true;" />
ok but now, method: Click_ButtonAdd is not executing :|
OnClientClick="this.value='Processing Credit Card
Payment...';this.disabled=true;return true;" />
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<laziers@.gmail.com> wrote in message
news:797d59f4-36db-4329-ba01-978d1ed74367@.j28g2000hsj.googlegroups.com...
>
>
> ok but now, method: Click_ButtonAdd is not executing :|
On 27 Lut, 13:55, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> OnClientClick="this.value='Processing Credit Card
> Payment...';this.disabled=true;return true;" />
>
the same :( "return true;" didnt help
:(
Aha, right, it is a different problem.
Disabled buttons don't fire postbacks.
You can do something like this:
OnClientClick="this.value='Processing Credit Card
Payment...';this.disabled=true;document.forms[0].submit()" />
It won't fire the server-side onclick event but will cause a postback. You
can communicate the action you want the server to take in a hidden input
field.
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<laziers@.gmail.com> wrote in message
news:1bfa439f-7cd3-47fd-855d-1e6fd9e4ea81@.34g2000hsz.googlegroups.com...
> On 27 Lut, 13:55, "Eliyahu Goldin"
> <REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> the same :( "return true;" didnt help
> :(
disabling after postback is trival.
<asp:button id="ButtonAdd"
runat="server"
text="Anuluj"
onclientclick="window.setTimeout(function(){this.disabled=true;};"
onclick="Click_ButtonAdd" />
but its a bad solution. if the postback takes too long and the user hits f5
(refresh), you will get a second postback. you should code for double
postbacks. render a transaction guid in a hidden field (or viewstate). then
store the guid with the payment posting. your code can then check if its bee
n
processed, and display the proper response.
-- bruce (sqlwork.com)
"laziers@.gmail.com" wrote:
> Hi,
> anyone know how to write a single-cilick button? [after click button
> is being disabled while the method is executing]
> I use this:
> <asp:button id="ButtonAdd" runat="server" text="Anuluj"
> onclick="Click_ButtonAdd" />
> if ( !isPostBack){
> ButtonAdd.Attributes.Add("onclick",
> ClientScript.GetPostBackEventReference(ButtonAdd, "") +
> ";this.value='Processing Credit Card Payment...';this.disabled =
> true;");
> }
> and I have with this a big problem.
> For time to time this method is executing 2 times. I dont know why.
> Instend of add 1 record to database it add 2 records.
>
Wednesday, March 28, 2012
single-click button / ajax
Labels:
ajax,
asp,
button,
buttonis,
click,
disabled,
executingi,
method,
net,
single-cilick,
single-click,
thisltaspbutton,
write
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment