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

determine if ajax update is occuring

1 Answer 61 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker asked on 25 Sep 2012, 08:47 PM
I have a two buttons on different pages which perform the same action. In one case, the button is ajaxified and in the other it is not. In the code which handles both button clicks, I need to call some client-side script. If the button is ajaxified, I simply add the script using  ajaxamanager.ResponseScripts.Add. In the nonajaxified scenario, I simply use RegisterScriptManagerScript.

My question is:

is there a way within code to tell if an ajax update is occurring. Like I said, I would like to have one function which handles the button cick in both scenarios. Within this function, I need a way to branch off and call the ajaxmanager code if an ajasupdate is occuring, and the other if it is not.

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 28 Sep 2012, 12:02 PM
Hi Albert,

You could handle the OnButtonClick events for the both buttons and use the following to check if the request is ajax request:

if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack)         
           {           
                   // Do something only when the page is partially posted back         
           }

I hope this helps.

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Answers by
Maria Ilieva
Telerik team
Share this question
or