<p>I've got a web application working using VB and Ajax. I'm using updatepanels to avoid the irritating "flicker" on postbacks to the server. </p>

<p>I would like to have a button control defined within the updatepanel itself (tried moving it outside and got some catastrophic error, so left it there) that  makes the current panel not visible and a sibling panel visible. This works with the exception that the button must be clicked twice. Not double clicked, but clicked once than clicked again. </p>

<p>In setting breakpoints I discovered the code behind that's attached to the button is actually being executed on the first click, but the panels don't switch as expected. If I click the same button OR worse yet, a different button, the expected behavior of the second panel appearing occurs. However, with the second button being clicked there's an unwanted bonus of a third panel being displayed, the third panel being made visible due to the second button being clicked.</p>

<p>I'm assuming this behavior is due to the updatepanel and its Ajax nature. Is there a way to avoid the second click? Am I misusing the updatepanel? I really wanted to use a modal popup (right out of the AjaxToolKit) but had problems with posting back the data so I opted for this approach. Any insights, assistance, even criticism would be welcome as this has plagued me long enough. Thanks</p>

[{'answer_id': 44459, 'author': 'Ryan Farley', 'author_id': 1627, 'author_profile': 'https://Stackoverflow.com/users/1627', 'pm_score': 1, 'selected': False, 'text': '<p>If you get rid of the UpdatePanels do things work as expected with PostBacks? Chances are something in your Page_Load or other event higher up the chain are "resetting" things in some way before it gets to your click event. Could this be the case?</p>\n'}, {'answer_id': 44471, 'author': 'Mike', 'author_id': 4523, 'author_profile': 'https://Stackoverflow.com/users/4523', 'pm_score': 0, 'selected': False, 'text': "<p>I have run into this before and resolved it, I just can't remember how.  I will try to find my old code and get back to you.  one thought, do you have EnablePartialRendering enabled in your scriptmanager? maybe try wrapping both containers in a third panel.</p>\n"}, {'answer_id': 44568, 'author': 'Oded', 'author_id': 1583, 'author_profile': 'https://Stackoverflow.com/users/1583', 'pm_score': 0, 'selected': False, 'text': '<p>Your update panel is sitting inside the other panels.</p>\n\n<p>Should that be the other way around? AFAIK only controls within the update panel will get updated in via the AJAX call.</p>\n'}, {'answer_id': 46573, 'author': 'Mike', 'author_id': 4523, 'author_profile': 'https://Stackoverflow.com/users/4523', 'pm_score': 1, 'selected': False, 'text': '<p>I think your problem is that only the update panel is receiving data from the server after the method executes.  The panel your are trying to change is outside of the update panel so it does not know that its properties have changed. </p>\n\n<p>You either need to do a full page postback or have the panel you wish to modify inside the update panel.</p>\n'}, {'answer_id': 259156, 'author': 'Ryan Lundy', 'author_id': 5486, 'author_profile': 'https://Stackoverflow.com/users/5486', 'pm_score': 0, 'selected': False, 'text': "<p>Here's a fairly simple solution.  (I was having the same problem this morning.)</p>\n\n<p>The UpdatePanel can't render stuff outside itself.  So, as you noticed, the updates are happening, but you're not seeing the result.</p>\n\n<p>The easiest solution is to force a full postback.  You can do that like this:</p>\n\n<pre><code>protected override void OnInit(EventArgs e)\n{\n    var scriptManager = ScriptManager.GetCurrent(this);\n    // or this.Page in a UserControl, etc.\n\n    scriptManager.RegisterPostBackControl(someButton);\n    scriptManager.RegisterPostBackControl(someOtherButton);\n    // etc. for each control that needs to update something outside the UpdatePanel\n}\n</code></pre>\n\n<p>This still allows the buttons themselves to be updated in the UpdatePanel by Ajax (e.g. changing their state to disabled or enabled).  The full postback only happens if the buttons are clicked.</p>\n"}, {'answer_id': 269424, 'author': 'TonyB', 'author_id': 3543, 'author_profile': 'https://Stackoverflow.com/users/3543', 'pm_score': 0, 'selected': False, 'text': '<p>Like others have said an update panel only updates its contents, thats one of the main benefits of using it.</p>\n\n<p>Panel2 and pnlPrvCmt need to be inside your update panel for your button click method to work.  Another option would be to put Panel2 inside one update panel and pnlPrvCmt inside a second update panel.  Then any control inside either update panel will cause both to refresh, as long as the UpdateMode=Always (which it is by default).</p>\n'}, {'answer_id': 20674021, 'author': 'Quintin Humphreys', 'author_id': 3117866, 'author_profile': 'https://Stackoverflow.com/users/3117866', 'pm_score': 0, 'selected': False, 'text': '<p>Try giving the dynamic control an ID when it is created.<br> For some reason this is required by .net for a dynamic control to work in this context.</p>\n\n<pre><code>myControl.id="newID"\n</code></pre>\n'}, {'answer_id': 26831239, 'author': 'Jason Gilley', 'author_id': 2699590, 'author_profile': 'https://Stackoverflow.com/users/2699590', 'pm_score': 0, 'selected': False, 'text': '<p>I have found this to occur under 2 different scenerios:</p>\n\n<ol>\n<li><p>No ID set on the control. Either the ID is left off of the markup or the the ID was not set when a dynamic control was created. ASP.Net uses the ID to track actions.</p></li>\n<li><p>Nested UpdatePanels. Scenerio: When using a Masterpage, you might have a content placeholder that you wrap in an UpdatePanel so that an UpdatePanel is not needed in the content on the page. Then, in developing your page you might, as a habit, add an UpdatePanel.</p></li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/44453', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']