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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Bad Behavior

Bad Behavior

Scheduled Pinned Locked Moved ASP.NET
7 Posts 3 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.
  • B Offline
    B Offline
    BobbyStrain
    wrote on last edited by
    #1

    I have a couple of ASP.NET web pages; the first page does a cross-page postback to the second. This second page has an AJAX update panel. The second page has a server-side button outside the update panel. The button runs JavaScript (onclientclick) to close the page and open the calling page, and it functions properly when the button is clicked. When I take some other action on page 2 that triggers an AJAX call, the JavaScript triggers, closes the page, and returns to the calling page. I changed the button to a server-side linkbutton with the same JavaScript and now the page behaves as it should. Is this one of the bad characteristics of the update panel?

    J 1 Reply Last reply
    0
    • B BobbyStrain

      I have a couple of ASP.NET web pages; the first page does a cross-page postback to the second. This second page has an AJAX update panel. The second page has a server-side button outside the update panel. The button runs JavaScript (onclientclick) to close the page and open the calling page, and it functions properly when the button is clicked. When I take some other action on page 2 that triggers an AJAX call, the JavaScript triggers, closes the page, and returns to the calling page. I changed the button to a server-side linkbutton with the same JavaScript and now the page behaves as it should. Is this one of the bad characteristics of the update panel?

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      server side controls just write HTML for you. In the time it takes to write a server control on the page, you could have just written plain HTML. You really need to look at the page source and look at the HTML that was written between the 2 server controls, button and link button. Since I cant see the page and examine the HTML, I cannot do any forensics on it. In the update panel, you can assign async postback triggers for a button to fire the assigned server function in a partial post back, in which a small round trip of the HTML inside the update panel is sent to the server as a partial post back, and HTML is sent back and replaced on the page within that container. You may of just made a mistake onClientClick, it should return false to stop a post back event. eg. onClientClick = "returnUrl(); return false;" I stopped using update panels over 6 years ago, because they were buggy and unreliable in terms of speed during a full load on the internet connection or distance; say across the country, and the user would always misinterpret the situation. I got way better at planning or engineering forms after that, just using jQuery or JavaScript to complete the task, or just do a full post back to the server. In fact better yet, I stopped using web forms completely and went MVC to produce much better work faster with higher quality.

      B 1 Reply Last reply
      0
      • J jkirkerx

        server side controls just write HTML for you. In the time it takes to write a server control on the page, you could have just written plain HTML. You really need to look at the page source and look at the HTML that was written between the 2 server controls, button and link button. Since I cant see the page and examine the HTML, I cannot do any forensics on it. In the update panel, you can assign async postback triggers for a button to fire the assigned server function in a partial post back, in which a small round trip of the HTML inside the update panel is sent to the server as a partial post back, and HTML is sent back and replaced on the page within that container. You may of just made a mistake onClientClick, it should return false to stop a post back event. eg. onClientClick = "returnUrl(); return false;" I stopped using update panels over 6 years ago, because they were buggy and unreliable in terms of speed during a full load on the internet connection or distance; say across the country, and the user would always misinterpret the situation. I got way better at planning or engineering forms after that, just using jQuery or JavaScript to complete the task, or just do a full post back to the server. In fact better yet, I stopped using web forms completely and went MVC to produce much better work faster with higher quality.

        B Offline
        B Offline
        BobbyStrain
        wrote on last edited by
        #3

        Thank you for your prompt response. I have been advised before to move to MVC with Razor. But I am too old to redo my site. Thus far I have been able to work around problems like this one; but I am always curious about the cause. I went to an update panel to avoid page jump back to the top on postback. If there is a simple way to avoid this, I would certainly look into it. I am looking at movint to jquery and HTML5.

        N 1 Reply Last reply
        0
        • B BobbyStrain

          Thank you for your prompt response. I have been advised before to move to MVC with Razor. But I am too old to redo my site. Thus far I have been able to work around problems like this one; but I am always curious about the cause. I went to an update panel to avoid page jump back to the top on postback. If there is a simple way to avoid this, I would certainly look into it. I am looking at movint to jquery and HTML5.

          N Offline
          N Offline
          Nathan Minier
          wrote on last edited by
          #4

          Generally I find web forms are "okay" when you're using the old-school postback model, but struggle greatly when it comes to handling AJAX. This is generally because the framework tries to hide the execution context from the developer, and UpdatePanels are about the worst offenders. I quickly replace any web forms application that is put in my care with a .NET MVC or a JavaScript SPA, depending on scale and needs. Just the maintenance problems alone warrant it, IMO. You're not going to get away from the client-vs-server side issues as long as you're using web forms.

          "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

          B 1 Reply Last reply
          0
          • N Nathan Minier

            Generally I find web forms are "okay" when you're using the old-school postback model, but struggle greatly when it comes to handling AJAX. This is generally because the framework tries to hide the execution context from the developer, and UpdatePanels are about the worst offenders. I quickly replace any web forms application that is put in my care with a .NET MVC or a JavaScript SPA, depending on scale and needs. Just the maintenance problems alone warrant it, IMO. You're not going to get away from the client-vs-server side issues as long as you're using web forms.

            "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

            B Offline
            B Offline
            BobbyStrain
            wrote on last edited by
            #5

            Nathan, Thank you for your advice. Is there any tool that can convert web pages to MVC? Or, do I need to build from scratch? I don't use any data handling on the pages except for login control. All of the pages gather input and present calculation results from VB code behind. Are these pages still usable in an MVC project? So far, it all still works. I'll have to have someone from China check the speed. I use Godaddy hosting. These servers may be in Australia.

            N 1 Reply Last reply
            0
            • B BobbyStrain

              Nathan, Thank you for your advice. Is there any tool that can convert web pages to MVC? Or, do I need to build from scratch? I don't use any data handling on the pages except for login control. All of the pages gather input and present calculation results from VB code behind. Are these pages still usable in an MVC project? So far, it all still works. I'll have to have someone from China check the speed. I use Godaddy hosting. These servers may be in Australia.

              N Offline
              N Offline
              Nathan Minier
              wrote on last edited by
              #6

              Honestly if it all still works I'd be surprised if you got any management support for re-coding the project. There are no tools that I'm aware of that will effectively parse out web forms into .NET MVC. I would assume up front than anything you write in .NET MVC will need to be fresh code, but can be informed by the business rules of pre-existing web forms applications.

              "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

              B 1 Reply Last reply
              0
              • N Nathan Minier

                Honestly if it all still works I'd be surprised if you got any management support for re-coding the project. There are no tools that I'm aware of that will effectively parse out web forms into .NET MVC. I would assume up front than anything you write in .NET MVC will need to be fresh code, but can be informed by the business rules of pre-existing web forms applications.

                "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

                B Offline
                B Offline
                BobbyStrain
                wrote on last edited by
                #7

                Nathan, Thanks for your affirmation. With the pace of change to web development things might look quite different in a couple years. So it seems that there is no easy transition. And you are right about convincing management. Because that is me, and I am also the owner. I built the site 10 years ago and have progressively upgraded content and function. This is a hobby, and so far some of the applications are free. But not the best stuff, which requires a subscription. I think what I will do is wait until the site no longer functions with developing technology. At that point, depending on when it comes, I'll move the applications to a cloud. Everything that is on the site I also have a desktop windows form application. I think that this can be served to clients securely so that the apps cannot be copied and distributed at will. My current project is to use SQLight with some of my applications that now use MS Access. But it seems that Microsoft doesn't play nicely with it. Sometimes it works; sometimes not.

                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