double postback?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/20/2007 4:50:27 PM
Gravatar
Total Posts 112

double postback?

Hi All,

In this thread Joe Audette suggested one of my problems sounds like double postback, that is clicking the second button before it has completed processing the first postback. You might try disabling the buttons using javascript after the first button is pushed and then re-enable it after processing the postback and that sounds right to me.

But I'm unsure about how I should go about disabling the buttons using javascript after the first button is pushed and then re-enable it after processing the postback...

Any suggestions are very much appreciated,
Dale E. Moore

6/20/2007 7:44:21 PM
Gravatar
Total Posts 18439

Re: double postback?

Hi Dale,

One example of how to prevent clicking a button again after it has been clicked is like this:

c#

btnMakePayment.Attributes.Add("onclick", "this.value='" + WebStoreResources.PaymentButtonDisabledText + "';this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnMakePayment, ""));

This example comes frome the e-commerce feature of mojoPortal (not a complated feature yet) found in the WebStore.sln solution, in the WebStore.UI project in Checkout.aspx.cs.

Note that this only prevents the clicked button from being clicked again. To disable all buttons you might call a javascript function

ex javascript:

disableButtons(){

var buttons = document.getElementsByTagName('button');
for (var i = 0, el; el = buttons[i]; i++) {
el.disabled = true;
}
}

server side c#:

btnMakePayment.Attributes.Add("onclick", "this.value='" + WebStoreResources.PaymentButtonDisabledText + "';disableButtons();" + Page.ClientScript.GetPostBackEventReference(this.btnMakePayment, ""));

if that doesn't work you might change one line of the javascript to:

var buttons = document.getElementsByTagName('input');

These are just ideas that should work in theory, not tested code except the first example which as I mentioned only disables the clicked button, not all the buttons.

Hope it helps,

Joe

6/26/2007 3:22:56 PM
Gravatar
Total Posts 112

Re: double postback?

My time for these projects comes and goes; and, I was just able to get back on it a few minutes ago. Thanks Joe for your suggestions about disbling buttons to avoid overlapping server activity and possible errors; that's a good idea!

Sadly I just tested the application before embarking on the button disabling effort and found that I couldn't make it fail.

You must sign in to post in the forums. This thread is closed to new posts.