Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem with update panel and javascript

problem with update panel and javascript

Scheduled Pinned Locked Moved ASP.NET
helpjavascripttoolsannouncement
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    unil Dhiman
    wrote on last edited by
    #1

    Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.

    U P 2 Replies Last reply
    0
    • U unil Dhiman

      Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.

      U Offline
      U Offline
      unil Dhiman
      wrote on last edited by
      #2

      i write aspx code thanks.

      1 Reply Last reply
      0
      • U unil Dhiman

        Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.

        P Offline
        P Offline
        Parwej Ahamad
        wrote on last edited by
        #3

        Register your script on page load event. OR you can try this: protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); Button1.Attributes.Add("onClick", "return msgg();"); } protected void Page_Load(object sender, EventArgs e) { //Button1.Attributes.Add("onClick", "return msgg();"); }

        /***********************/ Parwej Ahamad g.parwez@gmail.com /***********************/

        modified on Tuesday, March 4, 2008 10:35 PM

        U 1 Reply Last reply
        0
        • P Parwej Ahamad

          Register your script on page load event. OR you can try this: protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); Button1.Attributes.Add("onClick", "return msgg();"); } protected void Page_Load(object sender, EventArgs e) { //Button1.Attributes.Add("onClick", "return msgg();"); }

          /***********************/ Parwej Ahamad g.parwez@gmail.com /***********************/

          modified on Tuesday, March 4, 2008 10:35 PM

          U Offline
          U Offline
          unil Dhiman
          wrote on last edited by
          #4

          thanks Parwej. i did like this as you told. now wrror is not coming but when I click first time nothing happen. i mean javascript function not run. but second time it runs. can you give me any solution. thanks

          P 1 Reply Last reply
          0
          • U unil Dhiman

            thanks Parwej. i did like this as you told. now wrror is not coming but when I click first time nothing happen. i mean javascript function not run. but second time it runs. can you give me any solution. thanks

            P Offline
            P Offline
            Parwej Ahamad
            wrote on last edited by
            #5

            Did you registered on page load event ?

            Parwej Ahamad g.parwez@gmail.com

            U 2 Replies Last reply
            0
            • P Parwej Ahamad

              Did you registered on page load event ?

              Parwej Ahamad g.parwez@gmail.com

              U Offline
              U Offline
              unil Dhiman
              wrote on last edited by
              #6

              no. i remove from there. is it need. thanks

              1 Reply Last reply
              0
              • P Parwej Ahamad

                Did you registered on page load event ?

                Parwej Ahamad g.parwez@gmail.com

                U Offline
                U Offline
                unil Dhiman
                wrote on last edited by
                #7

                on button click event i fetch some data from databse base and then i use this data in javascript function, then i register this. i think when i will register on page load it will not work properly. thanks

                P 1 Reply Last reply
                0
                • U unil Dhiman

                  on button click event i fetch some data from databse base and then i use this data in javascript function, then i register this. i think when i will register on page load it will not work properly. thanks

                  P Offline
                  P Offline
                  Parwej Ahamad
                  wrote on last edited by
                  #8

                  Ok, I got your point You can do with hidden controls or session variable. When you clicked on button set the value in hidden variable or session variable and then access that variable in javascript function with the help getElementById method.

                  Parwej Ahamad g.parwez@gmail.com

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups