Page.ClientScript.RegisterStartupScript Not Working In Update Panel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 0301102
    New Member
    • Jul 2007
    • 6

    Page.ClientScript.RegisterStartupScript Not Working In Update Panel

    I using following script in my project. Once click the button and there will open a pop up window. But "Page.ClientScr ipt.RegisterSta rtupScript" script seem NOT working in update panel. After remove Update panel and it is working properly. Any solution?
    Code:
    Page.ClientScript.RegisterStartupScript(Me.GetType(), "openpopup", "window.open('" & "child.aspx" & "','ChildWindow','height = 520, width = 730,status=no,location=no,directories=no, resizable = 1, scrollbars=yes, left=75, top=75')", True)
  • ShahbazAshraf
    New Member
    • Mar 2008
    • 36

    #2
    Instead of using RegisterStartup Script use this Page.ClientScri pt.RegisterClie ntScriptBlock(a rguments) because RegisterStartup Script call the javascript before initallizing the DOM object while
    RegisterClientS criptBlock call after the page DOM objects initialized. May this was the issue ... if not then tell ...

    Comment

    • 0301102
      New Member
      • Jul 2007
      • 6

      #3
      Sorry, is not working. Any other solution? Ur help will be appreciate.

      Comment

      • 0301102
        New Member
        • Jul 2007
        • 6

        #4
        I found out the issue about my problem, seem the Page.ClientScri pt.RegisterStar tupScript() not working when included Master page. Any solution?

        Comment

        • ShahbazAshraf
          New Member
          • Mar 2008
          • 36

          #5
          Can u post the code here or related code here ?

          Comment

          • 0301102
            New Member
            • Jul 2007
            • 6

            #6
            finally i found out the problem, cause i'm using master page in my project, so the page will load twice. If i remove the master page, then it will load1 times. For the below mentioned script is working fine, but once i included master page for the below mentioned script, then it failed to run the script.Any method or solution to prevent master page load twice?

            'working fine & properly without master page
            Protected Sub OpenWindowWithU pdatePanel_Clic k(ByVal sender As Object, ByVal e As System.EventArg s)
            Dim url2 As String
            url2 = "ChildWindow.as px"

            ScriptManager.R egisterClientSc riptBlock(Me, Me.GetType(), "openpopup" , "window.ope n('" & url2 & "','OpenChildWi ndowUsingUpdate Panel','height = 520, width = 730,status=no,l ocation=no,dire ctories=no, resizable = 1, scrollbars=yes, left=75, top=75');", True)


            End Sub




            Regards
            Seng

            Comment

            • 0301102
              New Member
              • Jul 2007
              • 6

              #7
              finally i get the solution and solved my issue. The script ScriptManager.R egisterClientSc riptBlock() only working in .aspx and not working on .ascx. Anywhere thx for your help.

              Comment

              • ranjithpanakal
                New Member
                • Oct 2007
                • 2

                #8
                in the updatepanel use ScriptManager.R egisterStartupS cript Method..

                Comment

                • ZORBA
                  New Member
                  • Apr 2010
                  • 1

                  #9
                  it works in the ascx but the problem is for example you are passing this as an argument for the function example
                  ScriptManager.R egisterStartupS cript(this, typeof(Page), "OpenWindow","a lert('1'), "true);

                  try instead passing a control that is inside the updatepanel example
                  ScriptManager.R egisterStartupS cript(GridView1, typeof(Page), "OpenWindow","a lert('1'), "true);

                  Comment

                  • AnilkumarThumma
                    New Member
                    • Aug 2011
                    • 1

                    #10
                    use the following code it will dafinatley work
                    ScriptManager.R egisterStartupS cript(this.Page , this.Page.GetTy pe(), Guid.NewGuid(). ToString(), "alert('" "')", true);

                    Comment

                    Working...