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

Unable to execute custom javascript with Q2 2008 Ajax Manager

3 Answers 78 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 19 Sep 2008, 11:10 PM
See post below

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 19 Sep 2008, 11:16 PM

Wow, Google Chrome really doesn't like your forums at all. 

I will now attempt to redo my last post with IE:

I cannot get custom javascript to execute using the Q2 2008 Rad Ajax Manager.  I have done all the suggestions in this link http://www.telerik.com/help/aspnet/ajax/ajxcustomjavascript.html but to no avail.

This is the code behind of my test app where I am trying to get a simple javascript alert box to appear during an asynchronous post back:

   protected void Page_Load(object sender, EventArgs e)  
    {  
        Ajaxify();  
    }  
    protected void Ajaxify()  
    {  
        AjaxSettingsCollection settings = RadAjaxManager1.AjaxSettings;  
        settings.AddAjaxSetting(Button1, Label1);  
        settings.AddAjaxSetting(Button1, PlaceHolder1);  
    }  
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        Label1.Text = "hello world";  
        JavaScript();  
    }  
    protected void JavaScript()  
    {  
        StringBuilder sb = new StringBuilder();  
        sb.AppendLine("<script type=\"text/javascript\" language=\"javascript\">");  
        sb.AppendLine("alert(\"hello\");");  
        sb.AppendLine("</script>");  
        //ClientScript.RegisterStartupScript(Page.GetType(), "key", sb.ToString());  
        //RadAjaxManager1.ResponseScripts.Add(sb.ToString());  
        PlaceHolder1.Controls.Add(new LiteralControl(sb.ToString()));  
    } 

You will see that on lines 22 - 24 I have 3 different methods of executing that javascript when the Button1_Click event is triggered.  I tested each one individually, commenting out the other two, and not one of them produced an alert box.

Any and all help is greatly appreciated, thank you!
0
David
Top achievements
Rank 1
answered on 22 Sep 2008, 05:33 PM
Anyone here?
0
David
Top achievements
Rank 1
answered on 22 Sep 2008, 06:14 PM
Nevermind, I realized what I was doing wrong.  I was putting in the entire <script></script> tags, but failed to realize all I needed to do was put in the actual javascript code, so for example, this works fine:

RadAjaxManager1.ResponseScripts.Add(

"alert(\"hello\");");

Tags
Ajax
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Share this question
or