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

Script is called on every postback - how to prevent

4 Answers 40 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 18 Nov 2008, 04:06 PM
Hi.. I have the following code - to display a message box. But the code runs on every postback displaying the message. How do I prevent this?
thanks again

 

protected void btnPrintLabels_Click(object sender, EventArgs e)

 

{

RadAjaxManager1.ResponseScripts.Add(

@"Sys.Application.add_load(function()

 

{radalert('Under Construction...', 250, 100);})"

 

);

 

}

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 19 Nov 2008, 08:58 AM
Hi Jon,

Adding the script into the ResponseScripts collection will cause showing the message on each ajax request by default and this is the expected behaviour. Could you please let me know what functionality you need to achieve and what is the behaviour you required?

Regards,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jon
Top achievements
Rank 1
answered on 19 Nov 2008, 12:45 PM
Hi..
Once the button is clicked and the message is displayed - I only wait the message to display if they click the button. Not on all other postbacks or ajax requests... I want the message JUST for clicking that button.
thanks again
0
Maria Ilieva
Telerik team
answered on 19 Nov 2008, 02:52 PM
Hello Jon,

Please find attached a sample project which represents your scenario and which works as expected. Test it on your side and let me know what the difference in your case is.

Sincerely yours,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jon
Top achievements
Rank 1
answered on 19 Nov 2008, 03:01 PM
Thanks.. I see what you did.
Tags
Ajax
Asked by
Jon
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Jon
Top achievements
Rank 1
Share this question
or