开发者

Partial page refresh using an UpdatePanel

I have a page associated with master page. I need to implement the Ajax(basically wanted to to do partial page refresh). In this page I have grid and paging buttons(first/previous/last/next), dropdowns and also search. So all these updates the grid.开发者_Go百科

Right now I have below code

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

under

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

Here is the html like grid/buttons/search after ContentTemplate tag starts

So finally the page has left menu/footer/header and contents

</ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

But this is still refreshing the page.


I am a little confused as to you have and what you want.

It sounds like you have a Content control with an UpdatePanel in it. Within the UpdatePanel ContentTemplate you have all your grid, buttons etc along with your menu.

You only need to have the controls that you want to do the refresh in your UpdatePanel ContentTemplate. All the other stuff you should have outside of the UpdatePanel. If you have any controls outside of the UpdatePanel that you need to trigger a refresh with setup a Trigger for each control in the UpdatePanel and tell it which event to trigger off of.

Example:

<asp:Button ID="btnTest" runat="server" Text="Test" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <!-- only your content that needs refreshing goes here -->
    <ContentTemplate>
    <Triggers>
       <asp:AsyncPostBackTrigger ControlID="btnTest" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

In the above example the btnTest click event will cause the content of the UpdatePanel to refresh but the Button or anything outside of the UpdatePanel will not refresh. If the Trigger was not setup, the whole page would refresh. You don't need Trigger setup for controls within an UpdatePanel as all control events will be captured by the UpdatePanel for a refresh.

You can read up more on MSDN.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜