日期:2014-05-18  浏览次数:21064 次

Repeater嵌套UpdatePanel中的button事件
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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>无标题页</title>
  <style type="text/css" >
  .modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}
  </style>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <div class="demoarea">
  <div class="demoheading">ConfirmButton Demonstration 
  <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  </cc1:ToolkitScriptManager>
  </div>
  <asp:Repeater runat="server" ID="Repeater1" OnItemCommand="Repeater1_ItemCommand">
  <HeaderTemplate><table></HeaderTemplate>
  <ItemTemplate>
  <tr><td><%#Eval("testitem") %>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
  <asp:Button ID="Button" runat="server" Text="Click Me" CommandName="buy" /><br /> <cc1:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server" 
  TargetControlID="Button"
  OnClientCancel="cancelClick"
  DisplayModalPopupID="ModalPopupExtender1" />
  <br />
  <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button" PopupControlID="PNL" OkControlID="ButtonOk" CancelControlID="ButtonCancel" BackgroundCssClass="modalBackground" />
  <asp:Panel ID="PNL" runat="server" style="display:none; width:200px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
  Are you sure you want to click the Button?
  <br /><br />
  <div style="text-align:right;">
  <asp:Button ID="ButtonOk" runat="server" Text="OK" />
  <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" />
  </div>
  </asp:Panel>
   
  <asp:Label ID="Label1" runat="server" />
  </ContentTemplate>
  </asp:UpdatePanel>
  </td></tr>
  </ItemTemplate>
  <FooterTemplate>
  </table></FooterTemplate>
  </asp:Repeater>
   
  </div>