开发者

UpdatePanel and two content placeholder areas from a master page

开发者 https://www.devze.com 2023-02-25 06:21 出处:网络
I have a \"legacy\" ASP.NET site I\'d like to improve a bit. One area I\'d like to do something about is page updates - for now, it\'s always full page updates, but I\'d like to start using partial up

I have a "legacy" ASP.NET site I'd like to improve a bit. One area I'd like to do something about is page updates - for now, it's always full page updates, but I'd like to start using partial updates.

I was hoping to be able to use the ASP.NET UpdatePanel for this - but I'm a bit stuck on how to get this to work for me.

I have a master page which defines several content placeholders - simplified it looks like this:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Default.master.cs" Inherits="WebForms_Default" %>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>MyTitle</title>
</head>
<body>
   <form id="myForm" runat="server">
      <asp:ScriptManager ID="smgrMaster" runat="server" LoadScriptsBeforeUI="true">
         <Scripts>
            <asp:ScriptReference Path="~/Scripts/jquery-1.4.2.min.js" />
        开发者_C百科 </Scripts>
      </asp:ScriptManager>
      <asp:ContentPlaceHolder runat="server" ID="cphSearch" />
      <asp:ContentPlaceHolder runat="server" ID="cphContent" />
   </form>
</body>
</html>

On my content page, my grid is showing the data inside the cphContent area - and in my cphSearch area I have a number of input controls - a RadioButtonList and two DropDowns. Whenever something in those controls changes, for now, a postback is issued (they have AutoPostback="true" set).

My problem is: how do I tell my UpdatePanel (which I'm trying to wrap around my grid in the cphContent area) to "listen" for postbacks from those three controls from cphSearch ?

<asp:UpdatePanel>
   <ContentTemplate>
      <asp:GridView>
         // grid view defined here
      </asp:GridView>
   </ContentTemplate>
   <Triggers>
      <asp:AsyncPostBackTrigger ControlID=".. what values to put here?? .." />
      <asp:PostBackTrigger ControlID=".. - what values to put here?? .." />
   </Triggers>

When I add my <asp:UpdatePanel>, I get a section <Triggers>, but those controls in the cphSearch content area aren't visible, so I guess I can't really add them as update triggers, correct?

Either I'm totally not getting it (absolutely possible!), or I'm missing an obvious step / trick to get this to work - or it's just not possible. Let me know!


i think its not necessary to put Triggers all the time when you are not able to find control for Triggers some event just use updatepanel without triggers

<asp:Content ID="Content1" ContentPlaceHolderID="cphSearch" runat="Server">
  <asp:UpdatePanel ID="updateSearch" runat="server">
    <ContentTemplate>
       your searching controls
    </ContentTemplate>
  </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server">
  <asp:UpdatePanel ID="updateContent" runat="server">
    <ContentTemplate>
        your grid
    </ContentTemplate>
  </asp:UpdatePanel>
</asp:Content>

this will update whole grids, search controls and it will also handles AutoPostBack event but dnt forget to put Update <asp:UpdateProgress> control to see work is in process...


From the information, I assume you have your search controls on MasterPage that are common to all pages. One way would be to expose an event from your masterpage and handle it on your contentpage. Check this.

Upon your DDL selectedIndexChanged event you raise this event. Inside the handler of this event on contentPage you call updateContent.Update().

I think the solution lies somewhere along those lines.

0

精彩评论

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

关注公众号