troubleshooting Question

I try to trigger java from C# Using AJAX.

Avatar of RahnLev
RahnLev asked on
6 Comments1 Solution897 ViewsLast Modified:
I am Using an Image Button, I try to add java to its Click event among the C# code.
I am using Ajax for a local postback.
The AJAX is working fine, but the Java is not triggered from there.

I need to fix it.

I added Code
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <asp:ImageButton Height="110px"  ToolTip=""  
                         ID="PinkImageButton" Width="200px" runat="server" 
                         ImageUrl="~/Zimmer Pics/PinkRegular.png" onclick="PinkImageButton_Click"/>        
                <asp:AsyncPostBackTrigger EventName="Click" ControlID="PinkImageButton" />
 protected void PinkImageButton_Click(object sender, ImageClickEventArgs e)
              string String = "<script>" + AttributeString.ToString() + "</script>";
             // Define the name and type of the client scripts on the page.
             String csname1 = "PopupScript";
             String csname2 = "ButtonClickScript";
             Type cstype = this.GetType();
             // Get a ClientScriptManager reference from the Page class.
             ClientScriptManager cs = Page.ClientScript;
             // Check to see if the client script is already registered.
             if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
                 StringBuilder cstext2 = new StringBuilder();
                 cstext2.Append("<script type=\"text/javascript\"> function DoClick() {");
                 cstext2.Append(" alert('Hello World');   } </");
                 cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
             // Check to see if the startup script is already registered.
             if (!cs.IsStartupScriptRegistered(cstype, csname1))
                 String cstext1 = "DoClick();";
                 cs.RegisterStartupScript(cstype, csname1, cstext1, true);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros