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. Standard pattern for updating a tab in one click?

Standard pattern for updating a tab in one click?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpjavascriptasp-netdatabase
7 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.
  • A Offline
    A Offline
    alex3_14
    wrote on last edited by
    #1

    OK, I'm fairly green with ASP.net and I keep running into the same problem and I've solved it in various ways but none to my satisfaction. What I want: - To be able to click on a button/link or choose an option from a dropdownlist and have a tab be updated immediately with data supplied by the event set off by the button/link/dropdown. What I can do so far: - First click updates the tab and *then* sets the necessary variables that my tab needs to update properly. A second click re-updates the tab correctly. So, I use the OnClick event (or similar) of the button to set Session variables (values of which may come from a db) that the tab's OnLoad event needs to load itself properly. Unfortunately, the OnLoad of the tab happens before the OnClick of the button. Question: - What is the standard, non-javascript, way of making a C# function happen before the button engages the OnLoad event? Preferably I'd like the OnLoad to only happen once, but if the only way is for the thing to be set off twice, I can live with that. :)

    Alex

    F 1 Reply Last reply
    0
    • A alex3_14

      OK, I'm fairly green with ASP.net and I keep running into the same problem and I've solved it in various ways but none to my satisfaction. What I want: - To be able to click on a button/link or choose an option from a dropdownlist and have a tab be updated immediately with data supplied by the event set off by the button/link/dropdown. What I can do so far: - First click updates the tab and *then* sets the necessary variables that my tab needs to update properly. A second click re-updates the tab correctly. So, I use the OnClick event (or similar) of the button to set Session variables (values of which may come from a db) that the tab's OnLoad event needs to load itself properly. Unfortunately, the OnLoad of the tab happens before the OnClick of the button. Question: - What is the standard, non-javascript, way of making a C# function happen before the button engages the OnLoad event? Preferably I'd like the OnLoad to only happen once, but if the only way is for the thing to be set off twice, I can live with that. :)

      Alex

      F Offline
      F Offline
      fred_
      wrote on last edited by
      #2

      google ASP.NET page life cycle. The on load event will ALWAYS occur before the On click event. Once you understand the cycle better it will help you rearrange your code to fit it to get the desired results

      A 1 Reply Last reply
      0
      • F fred_

        google ASP.NET page life cycle. The on load event will ALWAYS occur before the On click event. Once you understand the cycle better it will help you rearrange your code to fit it to get the desired results

        A Offline
        A Offline
        alex3_14
        wrote on last edited by
        #3

        That's my question: How *do* I rearrange my code to fit the desired result? Or, is there some AJAXy thing I can do to the button that will allow code to run first and then load a control? (I should have mentioned that I have looked at the page lifecycle and I still have no idea how to accomplish what I need. My workaround so far has been requiring a selection of an item (datagrid selection, dropdown selection, etc.) and then a button click to confirm the selection.)

        Alex

        F 1 Reply Last reply
        0
        • A alex3_14

          That's my question: How *do* I rearrange my code to fit the desired result? Or, is there some AJAXy thing I can do to the button that will allow code to run first and then load a control? (I should have mentioned that I have looked at the page lifecycle and I still have no idea how to accomplish what I need. My workaround so far has been requiring a selection of an item (datagrid selection, dropdown selection, etc.) and then a button click to confirm the selection.)

          Alex

          F Offline
          F Offline
          fred_
          wrote on last edited by
          #4

          You had not indicated it was in a ajax call. Typically when an item is not updated in a ajax call even though you attempt to on the server side, the item that does not update isn't in the ajax container that is being updated and therefore doesn't change on the client but the server thinks it has still. A 2nd postback reveals the change. edit for typo

          modified on Wednesday, March 25, 2009 8:58 AM

          A 1 Reply Last reply
          0
          • F fred_

            You had not indicated it was in a ajax call. Typically when an item is not updated in a ajax call even though you attempt to on the server side, the item that does not update isn't in the ajax container that is being updated and therefore doesn't change on the client but the server thinks it has still. A 2nd postback reveals the change. edit for typo

            modified on Wednesday, March 25, 2009 8:58 AM

            A Offline
            A Offline
            alex3_14
            wrote on last edited by
            #5

            Well, in this case, the problem is that I click the button and... 1. The tab, I want updated, gets updated with old information thanks to obsolete session variables and whatnot. 2. The C# code executes - changing the session variables to the values I need (the values being decided by which GridView row the user selected and/or by querying the db). Result: A tab with old information. What would I need to do to recover the correct values I need and then update the tab with one click/selection?

            Alex

            F 1 Reply Last reply
            0
            • A alex3_14

              Well, in this case, the problem is that I click the button and... 1. The tab, I want updated, gets updated with old information thanks to obsolete session variables and whatnot. 2. The C# code executes - changing the session variables to the values I need (the values being decided by which GridView row the user selected and/or by querying the db). Result: A tab with old information. What would I need to do to recover the correct values I need and then update the tab with one click/selection?

              Alex

              F Offline
              F Offline
              fred_
              wrote on last edited by
              #6

              make sure the tab is part of the ajax update. Make the changes in the onclick event. Is the tab in a update panel that is updated by the button? If not your changes will not be visible until another postback occurs. On sucessful execution of a ajax call, only items in the panel for that update change on the client. The server side viewstate however is updated with all changes. When a 2nd post back occurs, the changes from the viewstate end up showing on the client. I don't know how to be more specific.

              A 1 Reply Last reply
              0
              • F fred_

                make sure the tab is part of the ajax update. Make the changes in the onclick event. Is the tab in a update panel that is updated by the button? If not your changes will not be visible until another postback occurs. On sucessful execution of a ajax call, only items in the panel for that update change on the client. The server side viewstate however is updated with all changes. When a 2nd post back occurs, the changes from the viewstate end up showing on the client. I don't know how to be more specific.

                A Offline
                A Offline
                alex3_14
                wrote on last edited by
                #7

                I think I'll be able to figure it out from there - thanks for all the help.

                Alex

                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