This is a migrated thread and some comments may be shown as answers.

PostBack issue

9 Answers 97 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
El
Top achievements
Rank 1
El asked on 07 Oct 2009, 03:17 PM
How do you enable button back if an IF statement in the code-behind uses Exit Sub method?
I have this JavaScript code which disable the button when the event is triggered and then enable it back when it ends up.

        function RequestStart(sender, args) 
        { 
           args.EventTargetElement.disabled = true
        } 
        function ResponseEnd(sender, args) 
        { 
           args.EventTargetElement.disabled = false;  
        } 

Say that i have this code behind:
If Expression Then 
   ' i want to enable the button here 
   Exit Sub 
End If 

Thanks


9 Answers, 1 is accepted

Sort by
0
El
Top achievements
Rank 1
answered on 08 Oct 2009, 01:35 PM
Any ideas? Thank you so much
0
Wim van der Linden
Top achievements
Rank 1
answered on 08 Oct 2009, 03:29 PM
Hey el,

Do you create the button from markup or from code?
Because you have to make sure the button gets reinitialized and readded to your page
before you exit your method (at least assuming the method breaks the load).

As far as I know you should be able to change the enabled property of your button in any other case.
(your button is within an updatepanel right?)

I know this answer is a long shot.

Kind regards,
Wim
0
Wim van der Linden
Top achievements
Rank 1
answered on 08 Oct 2009, 03:30 PM
oops double post
0
El
Top achievements
Rank 1
answered on 08 Oct 2009, 04:30 PM
hmm i am not sure i understand your question.

it is a standard ASP.NET button:
<asp:Button ID="MyButton" runat="server" Text="Process" CausesValidation="true" />  


And yes, it is included in the RadAjaxManager e.g.
<telerik:AjaxSetting AjaxControlID="MyButton"
      <UpdatedControls>                 
             <telerik:AjaxUpdatedControl ControlID="MyButton" /> 
      </UpdatedControls> 
</telerik:AjaxSetting>  

0
Wim van der Linden
Top achievements
Rank 1
answered on 08 Oct 2009, 07:12 PM
Hi El,

I tried to create a simple page doing what you say and it seems to work for me
this is my code:

page:
   <form id="form1" runat="server"
    <telerik:RadScriptManager ID="scriptManager" runat="server" ></telerik:RadScriptManager> 
   <telerik:RadScriptBlock runat="server"
   <script> 
     function RequestStart(sender, args) { 
         debugger; 
           args.EventTargetElement.disabled = true;  
        }  
        
  
        </script> 
    </telerik:RadScriptBlock> 
    <telerik:RadAjaxManager runat="server" ClientEvents-OnRequestStart="RequestStart" 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="MyButton"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="MyButton" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <div> 
        <asp:Button ID="MyButton" runat="server" Text="Process" CausesValidation="true"  /> 
    </div> 
    </form> 

code behind:

  Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) 
 
        MyBase.OnLoad(e) 
 
        Threading.Thread.Sleep(5000) 
 
        If scriptManager.IsInAsyncPostBack Then 
            MyButton.Enabled = True 
            Exit Sub 
 
        End If 
    End Sub 

this seems to work fine on my end, but perhaps I misunderstood your question?

kind regards,
Wim
0
El
Top achievements
Rank 1
answered on 09 Oct 2009, 08:36 AM
This is the scenario, you click the button, then it authorizes the Credit card and if it's ok it saves data into Database and finally it redirects you to another page ... ConfirmOrder.aspx
In my case it does everything but sometimes (quite often) you are never redirected to the ConfirmOrder page. Means it auth the cc and got saved the data into db but you are not redirected. It seems like nothing's happened. 

Any ideas why this happens?

0
Wim van der Linden
Top achievements
Rank 1
answered on 09 Oct 2009, 09:10 AM
Hey el,

not really sure about that, never ran into a case where a redirect was not executed.
However have you tried using the redirect on the RadAjaxManager instead?

kind regards,
Wim
0
El
Top achievements
Rank 1
answered on 09 Oct 2009, 09:25 AM
that's exactly what i am doing. RadAjaxManage1.Redirect
0
Wim van der Linden
Top achievements
Rank 1
answered on 09 Oct 2009, 10:13 AM
Hey el,

It appears that the RadAjaxManager.Redirect does not change the page for me either.
I'm just using the response.redirect since there is not reason for me to use the ajaxmanager.

Is there any reason why you need the RadAjaxManagers redirect?
Since I would expect that you want to reload the page since it's a redirect.

The RadAjaxManagers redirect works for example when you want to show a download dialog
in an ajax callback.

I hope this helps,

Wim
Tags
Ajax
Asked by
El
Top achievements
Rank 1
Answers by
El
Top achievements
Rank 1
Wim van der Linden
Top achievements
Rank 1
Share this question
or