Disable Button - HOW

This is quoted from a tread from Jun 2013

Hi,

I’ve been trying to get this to work and have had limited success.

I got the Progress bar to Show and then Hide, But can’t get the button to be disabled.

In a button Action I Have

    btnNext.Enabled = False
    prgProgress.Visible = True    '<----- WebProgressBar in Intermediate Mode
    
    Timer1.Mode = Timer.ModeSingle
    

In Timer I Have:

  SendAuthorizeNet   '<----------Sends CC info off to be authenticated
  prgProgress.Visible = False
  

The btnNext never gets set to Enabled = False

Does anybody have an idea Why

[quote=84873:@Richard Albrecht]The btnNext never gets set to Enabled = False

Does anybody have an idea Why[/quote]

I do not know why the enabled property would not work. However, there is a workaround.

btnNext is part of you app, right ? Simply add a conditional return on top of its Action event :

if btNextEnabled = false then return

btNextEnabled is a window or module scope boolean property that you use to prevent or enable execution of the Action event code.

[quote=84873:@Richard Albrecht]The btnNext never gets set to Enabled = False
Does anybody have an idea Why[/quote]
What make you think the Button never gets set to Enabled = False ?

  1. Because you can still click on It and it will repeat the Action ?
  2. Because when you hover the mouse it still changes its visual state ?
  3. Because you checked its value in the WebTimer and it is still set to False ?

Because it is not grayed out.

Right, and it won’t. You have to set your own WebStyle for this.

But the button is actually disabled, meaning if you click on it, it won’t fire an Action event anymore.

But I have other buttons that Show Disabled???

Hmm… I forgot I actually always use Rectangles to create ‘buttons’ and manage their states ‘manually’ with WebStyles.

If Standard Button are supposed to ‘show’ a disabled state whenever you disabled those, then it must be either:

  1. A timing issue (the button never receive the command to disable itself)
  2. You have overridden the Standard button look with a WebStyle ?

Don’t know about 1, will have to investigate.

As far as 2, nope it’s a standard button.

I’ve re-red your first post an noticed you mention:

[quote]In a button Action I Have:
btnNext.Enabled = False
[/quote]

Shouldn’t it be:
Me.Enabled = False

?

Did a quick experiment on Mac and Windows by setting two buttons on a window and placing code to switch enabled between them. It works fine. The disabled button is grayed out.

You may want to run the same test. Then go through your code to see what is wrong.

Is SendAuthorizeNet a sync or asynchronous call? If the latter, it may be that the button is being disabled/enabled so quickly that you don’t see it.

Except that his code above doesn’t re-enable the button. Plus, he states that the progress bar does appear then disappear, so that would seem to prove that SendAuthorizeNet is a synchronous call, and that the page is being updated.

Richard, what is the period of the timer? And are you sure that the button is named btnNext? Maybe that is really another button that you don’t realize is being set. Using Me instead of btnNext as Guy suggested would ensure you’re controlling the correct one.

Here’s the actual call in SendAuthorizeNet:

result = S.Post("https://secure.authorize.net/gateway/transact.dll", 30) // Synchronous

The btnNext is the name, The timer is set to 1000.

I can’t use me as the Button Action calls a much larger function, thats where this is called.

[quote=85303:@Richard Albrecht]Here’s the actual call in SendAuthorizeNet:

result = S.Post("https://secure.authorize.net/gateway/transact.dll", 30) // Synchronous

The btnNext is the name, The timer is set to 1000.

I can’t use me as the Button Action calls a much larger function, thats where this is called.[/quote]

Have you tried to create a test project containing buttons and code to enable/disable them ? Or add a button on your page that simply contains btnNext.Enabled = False to check the result ?