Click here to Skip to main content
12,509,148 members (55,410 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
i know that i didn't describe the problem clearly but believe that i have no idea how should i explain it.

The button is rising the following event in parent page, but the javascript alert doesn't fire, do you have any idea?
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnContinue2" runat="server" OnClick="btnContinue2_Click"       Text="Button" />
    </ContentTemplate>
</asp:UpdatePanel>
i put a break point in the InsertLocationMap_MyEvent, so everything is fine until there but the alert box doesn't popup, is the reason that there is no postback ?

protected void Page_Load(object sender, EventArgs e)
       {
           InsertLocationMap.MyEvent += InsertLocationMap_MyEvent;
 
       }
 
       void InsertLocationMap_MyEvent(object sender, usercontrols.cp_user.MyEventArgs e)
       {
 
           string javaScript = "<script language="JavaScript"> alert('wwwoww'); </script>";
          System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JCall2", javaScript, false);
 
       }
Posted 8-Dec-12 21:12pm
Comments
Krunal Rohit 9-Dec-12 3:17am
   
On which control you're firing InsertLocationMap_MyEvent ??
Christ_88 9-Dec-12 3:24am
   
in the child usercontrol the button (btnContinue2) fire the event but i pass it to parent page by eventhandler and the InsertLocationMap_MyEvent is called in parent page.
and i need call a javascript function in that. all these should happen without postback
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

string javaScript = "<script language="JavaScript"> alert('wwwoww'); </script>";
           System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JCall2", javaScript, false);
Or you can also do the same by

System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JCall2", "alert('Hello')", Yes);
  Permalink  
v3
Comments
Christ_88 19-Dec-12 22:00pm
   
thank you for the answer
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi,

Check this url

http://www.codeproject.com/Questions/456037/Javascript-not-working-inside-Updatepanel
  Permalink  
Comments
Christ_88 19-Dec-12 22:00pm
   
thank you for the answer, that work for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100