Книга: C# 2008 Programmer

Using the UpdatePanel Control

Using the UpdatePanel Control

To delineate the part of the page you want to update without causing the entire page to refresh, drag and drop an UpdatePanel control from the AJAX Extensions tab of the Toolbox onto the Default.aspx page, like this:

 <form runat="server">
   <asp:ScriptManager runat="server">
   Display titles by publisher:
  <asp:UpdatePanel runat="server">

The <asp:UpdatePanel> control divides a web page into regions — each region can be updated without refreshing the entire page. The <ContentTemplate> element sets the template that defines the contents of the <asp:UpdatePanel> control.

Now, move a GridView control into the <ContentTemplate> element so that the content of the GridView can be updated without causing a postback to the server:

<asp:UpdatePanel runat="server">
  <asp:GridView runat="server" AllowPaging="True"
   AutoGenerateColumns="False" BackColor="LightGoldenrodYellow"
  </asp:GridView >

Press F5 to test the application again. This time, edit the record by clicking the Edit link (see Figure 17-26). Notice that, as you click on the links (Edit, Update, Cancel, and Select), the page does not reload. Instead, all the changes happen inside the GridView control.

Figure 17-26

Оглавление книги

Генерация: 1.020. Запросов К БД/Cache: 3 / 1
Вверх Вниз