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.
-
Disabling a Trigger Control During Asynchronous PostBack
Often, we want to disable the control that triggered an asynchronous postback until the postback has completed. This prohibites the user from triggering another postback until the current one is complete.
-
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.
-
Easy SQL “If Record Exists, Update It. If Not, Insert It.”
A very common scenario is the one where we want to update the information in a record if it already exists in the table, and if it doesn’t exist, we want to create a new record with the information.
-
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.
-
Controlling the ASP.NET Timer Control with JavaScript
Have you ever wanted to control your <asp:Timer> control from client-side code?
-
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.