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

[Solved] execution moment of OnRequestStart

5 Answers 114 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Greet
Top achievements
Rank 1
Greet asked on 14 Oct 2008, 10:45 AM
Hello all,

I have the followwing RadAjaxManager

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

<ClientEvents OnRequestStart="javascript: BeforeUpdateLijsten()" />

 

<AjaxSettings>

 

<telerik:AjaxSetting AjaxControlID="linkButtonToevoegen" EventName="click">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="radGridPercelen" />

 

 

</UpdatedControls>

 

 

</telerik:AjaxSetting>

 

 

</AjaxSettings>

 

 <

/telerik:RadAjaxManager>

The javascript function "BeforeUpdateLijsten" needs to be execute before the back end code.

In the function BeforeUpdateLijsten I update the value of a hiddenField and in the back-end code I read the value of this hiddenField. All the code gets executed but in the back-end I get the old value from the hiddenField.

Can anyone tell me why this is happening and how I can solve this?
Thank you!

 

 

 

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 16 Oct 2008, 11:05 AM
Hi Greet,

Please review the following online help topic which elaborate on similar matter. Test the provided approach and let us know if this helps.

Greetings,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Greet
Top achievements
Rank 1
answered on 16 Oct 2008, 01:49 PM
Hi Maria,

Thank you for you're response.

With ResponseScripts as described in the help topic, the code behind will be executed before the javascript. I need the javascript to be executed before the code behind.

With OnRequestStart I get the correct execution order but in the code behind I get the old value of the hiddenField (In the javascript function I set the hiddenfield to another value).

It looks like there is already a part (viewstate?) of the request send when OnRequestStart is executed.

Greetings
Greet
0
Maria Ilieva
Telerik team
answered on 20 Oct 2008, 12:11 PM
Hi Greet,

Could you please send us your sample project, which represents this behaviour, via regular support ticket. We will debug it locally and do our best to provide accurate solution for this issue.

Thank you for the cooperation.

Kind regards,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bill O'Neil
Top achievements
Rank 1
answered on 14 May 2009, 12:03 PM
Was this ever solved?  I have the same issue - I have some javascript that needs to execute BEFORE the callback (and it changes a field value) - when I do this during ONREQUESTSTART - the changed value is not seen upon postback.  Any way to make this work?
0
Bill O'Neil
Top achievements
Rank 1
answered on 14 May 2009, 12:09 PM
Still hoping for a better solution - but I had to write a clunky script that cancels the callback, changes the values and then initiates the callback again:

        var bypass = false;
        function OnRequestStart(ajaxControl, eventArgs) {
            var eventTarget = eventArgs.EventTarget;
            if (((eventTarget.indexOf("btnInsert") >= 0) || (eventTarget.indexOf("btnUpdate") >= 0)) && !(bypass)) {
                eventArgs.set_cancel(true);
                bypass = true;
                saveLinks(); //this is what updates the values
                $find("<%=ap1.ClientID%>").ajaxRequestWithTarget(eventTarget, '')
            }
            bypass = false;
            return true;
        }        

Tags
Ajax
Asked by
Greet
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Greet
Top achievements
Rank 1
Bill O'Neil
Top achievements
Rank 1
Share this question
or