Andrew Frederick

  • Handling Multiple Asynchronous Postbacks

    Sometimes multiple asynchronous postbacks get triggered. Now, I’m not talking about situations where we want to disable a submit button, so that the user doesn’t click it fifty times waiting for something to happen. Instead, I’m referring to situations where we do want each postback to happen in the order it was fired.

  • Maintain Scroll Position after Asynchronous Postback

    Do you want to maintain the scroll position of a GridView, Div, Panel, or whatever that is inside of an UpdatePanel after an asynchronous postback?  Normally, if the updatepanel posts back, the item will scroll back to the top because it has been reloaded.  What you need to do is “remember” where the item was scrolled to and jump back to there after the postback.  Place the following script after the ScriptManager on your page.  And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item move!

  • Selecting an AJAX AccordionPane by ID

    Typically, if we want to programmatically select a particular AccordionPane within an ASP.NET AJAX Accordion control, we set the SelectedIndex property.  This is great if we know the exact order of our AccordionPanes at all times, but this isn’t always so.  Let’s say, for instance, that you have four panes (making their indices 0, 1, 2, and 3, respectively).  If we make the third one (index 2) invisible, now the fourth one has an index of 2.  So let’s create a method to select the AccordionPane by its ID instead.

  • View Source Trick for Pages with Partial Rendering

    Many people when developing want to look at the browser’s View Source to make sure that things are being outputted correctly or to see where in the DOM certain things are showing up. However, if you are using the Ajax concept of partial rendering (usually via UpdatePanels), what you get is the initial state of the page when it was first loaded before any partial page updates, not the state of the page as it is currently.

  • A Client-side Ajax Login for ASP.NET

    A question was posed on the ASP.NET forums recently asking how to have a login control that doesn’t refresh the page.  The ideal solution would be to just drop an ASP.NET Login control inside an updatepanel.  However, the Login control (along with PasswordRecovery, ChangePassword, and CreateUserWizard controls whose contents have not been converted to editable templates) is not supported inside an UpdatePanel.  They are just not compatible with partial-page updates.