How To Work with Update Panels and Content Templates - ASP.NET AJAX
Video Transcript
Now that is the partition in our page to control how the updates occur. Double click on the product catalog, go to design. In the sub categories dropdown, let us say that that data does not change that often. In that case, we do not want to refresh it on every single post back, do we? However, we want the data in the good view to only get refreshed when the user selects something in the dropdown. But we do not want to refresh the drop down each time. Let us build that logic. We can do this with the update panel.
Besides the script manager, the update panel is the most often used control in ASP.NET AJAX. The update panel enables you to divide your page into refreshable components that can update independently of one another. The update panel is a server side control that enables you to do partial page refreshes. It only updates the content that is inside the update panel. Only those elements will get updated. The rest of the page will not get refreshed. The update panel is our way of indicating nothing on the page but what is in this update panel should refresh.
So that is what we want to do with the grid view. Go to source mode, and at the top of the cell for the products grid, we are going to drag over an update panel. Navigate your cursor, and go to the AJAX tab, there you will see the update panel. Let us drag that over. Now, let us give it an intelligent name, we will call it update panel products. The next thing we need to do is add a content template tag inside of our update panel. This content template is a place holder for the content that we wish to put inside.
Now, let us organize the contents of our update panel. Cut this code and place it inside of the table cell. Then what we want to do is take these closing tags and move them down to after our label ID. Let us take a look at our work. What we did was we encapsulated the grid view and its respective columns inside of a content template. We also had a label control inside of our content template, this way we have an indicator to tell us when this content inside the update panel was last refreshed.
Now that is the partition in our page to control how the updates occur. Double click on the product catalog, go to design. In the sub categories dropdown, let us say that that data does not change that often. In that case, we do not want to refresh it on...
click to read more