ASP.NET AJAX : Dynamically Pushed JavaScript not working after being pushed to UpdatePanel's content

Discussion in 'ASP .Net' started by Arachnid, Oct 5, 2007.

  1. Arachnid

    Arachnid Guest

    Hi all,

    I am trying something using ASP.NET AJAX.
    Using postback i am adding a JavaScript snippet and a DIV inside a
    panel in UPdatePanel.The HTML is shown. The Javascript is written too.
    But JavaScript is not working.

    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
    <asp:ScriptReference Path="FusionCharts.js" />
    </Scripts>
    </asp:ScriptManager>

    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <script language="javascript" type="text/javascript">
    var XML="<chart/>";
    </script>

    <asp:panel ID="p" runat="server" Height="262px"
    Width="341px">
    please click on the button</asp:panel>
    <asp:Button ID="Button1" runat="server"
    OnClick="Button1_Click" Text="Button" />
    </ContentTemplate>
    </asp:UpdatePanel>


    <asp:UpdateProgress ID="UpdateProgress1" runat="server"
    DisplayAfter="0">
    <ProgressTemplate>
    delay............................
    </ProgressTemplate>
    </asp:UpdateProgress>
    </form>
    <script language="javascript" type="text/javascript">
    function pageLoad(){
    alert($get('p').innerHTML);
    }

    </script>

    </body>
    </HTML>
    ---------------- CODE BEHIND --------------------

    protected void Button1_Click(object sender, EventArgs e)
    {
    string str = "<div id='Update'>HI</div>";
    str += "<script language='Javascript' type='text/
    javascript'>document.getElementById('Update').innerHTML='latest
    updated hiiiiiiiiiiii!!!';</script>";
    System.Threading.Thread.Sleep(3000);
    p.Controls.Add(new LiteralControl(str));

    }

    =================================================================

    I am using the general ScriptManager coltrol and UpdatePanel that has
    a PANEL having an id 'p'.
    >From the server side postback i am changing this panel's HTML to


    <div id='Update'>Hi</div><script language='Javascript' type='text/
    javascript'> document.getElementById('Update').innerHTML='latest
    updated hiiiiiiiiiiii!!!';</script>

    I can see the div being parsed by the browser. But the <script> is not
    taken care of by the browser.


    PLease, please, please help me out of this.

    Am i going wrong somewhere? IS there any way out?

    Please help me.


    - Arachnid
    Arachnid, Oct 5, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad

    Button not being pushed on Enter

    tshad, Aug 11, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    368
    Steve C. Orr [MVP, MCSD]
    Aug 12, 2005
  2. Chris
    Replies:
    5
    Views:
    975
    Chris
    Feb 21, 2007
  3. Andrew Jocelyn
    Replies:
    2
    Views:
    824
    Steven Cheng
    Mar 12, 2008
  4. cwdjrxyz
    Replies:
    0
    Views:
    340
    cwdjrxyz
    Apr 28, 2009
  5. shajnday
    Replies:
    0
    Views:
    333
    shajnday
    Oct 14, 2011
Loading...

Share This Page