这是我的aspx页面中的代码......
<asp:UpdatePanel ID="WorkItemPanel" UpdateMode="Conditional" ChildrenAsTriggers="False" runat="server">
<ContentTemplate>
<table class="WorkItemTable">
<tr>
<th class="WorkItemTable" style="background-color: #eeeeee; width: 170px;"><div style="font-weight: bold; width: 170px; padding: 5px;" id="createpb" runat="server">Product Backlog</div>
<div id="createpbMenu" class="ContextMenuPanel" style="display: none" runat="server">
<UC:CreateProductBacklogMenu ID="CreateProductBacklogMenu" runat="server"></UC:CreateProductBacklogMenu>
</div>
<ajaxToolkit:DropDownExtender runat="server" ID="DDE"
TargetControlID="createpb"
DropDownControlID="createpbMenu" />
</th>
<th class="WorkItemTable" style="width:50%;"><b>Not Done</b></td>
<th class="WorkItemTable" style="width: 158px;"><div style="width: 158px;"><b>In Progress</b></div></td>
<th class="WorkItemTable" style="width: 158px;"><div style="width: 158px;"><b>Ready For Test</b></div></td>
<th class="WorkItemTable" style="width:50%;"><b>Done</b></td>
</tr>
<asp:Repeater runat="server" ID="productBacklog" EnableViewState="false">
<ItemTemplate>
<tr>
<td class="WorkItemTable" valign="top" style="width: 170px;height: 100%">
<UC:ProductBacklogView onSomethingButtonClick="" id="pbv" PB=<%# Container.DataItem %> runat="server"></UC:ProductBacklogView>
</td>
<td class="WorkItemTable DropTarget State-NotDone" valign="top" style="width:50%;">
<asp:Repeater DataSource=<%#GetStatus(Eval("ID"),"Not Done")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-InProgress" valign="top" style="width: 158px;">
<asp:Repeater ID="Repeater1" DataSource=<%#GetStatus(Eval("ID"),"In Progress")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-ReadyForTest" valign="top" style="width: 158px;">
<asp:Repeater ID="Repeater4" DataSource=<%#GetStatus(Eval("ID"),"Ready For Test")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-Done" style="width:50%;" valign="top">
<asp:Repeater ID="Repeater2" DataSource=<%#GetStatus(Eval("ID"),"Done")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #F6F6F6;">
<td class="WorkItemTable" valign="top" style="width: 170px;">
<UC:ProductBacklogView ID="ProductBacklogView1" PB=<%# Container.DataItem %> runat="server"></UC:ProductBacklogView>
</td>
<td class="WorkItemTable DropTarget State-NotDone" valign="top" style="width:50%;">
<asp:Repeater ID="Repeater3" DataSource=<%#GetStatus(Eval("ID"),"Not Done")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-InProgress" valign="top" style="width: 158px;">
<asp:Repeater ID="Repeater1" DataSource=<%#GetStatus(Eval("ID"),"In Progress")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-ReadyForTest" valign="top" style="width: 158px;">
<asp:Repeater ID="Repeater4" DataSource=<%#GetStatus(Eval("ID"),"Ready For Test")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
<td class="WorkItemTable DropTarget State-Done" style="width:50%;" valign="top">
<asp:Repeater ID="Repeater2" DataSource=<%#GetStatus(Eval("ID"),"Done")%> runat="server">
<ItemTemplate>
<UC:WorkItemView CssClass=<%#GetWorkItemCssClass(Container.DataItem)%> ID="WorkItemView1" SB=<%# Container.DataItem %> runat="server"></UC:WorkItemView>
</ItemTemplate>
</asp:Repeater>
</td>
</AlternatingItemTemplate>
</asp:Repeater>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="viewSprintButton" />
</Triggers>
</asp:UpdatePanel>
我的UserControl是ProductBacklogView(存在于转发器内)。我试图在aspx中做这样的事情......
productBacklog.ItemDataBound += new RepeaterItemEventHandler(productBacklog_BindAddButton);
DataBind();
}
void productBacklog_BindAddButton(object sender, RepeaterItemEventArgs e)
{
Button btn = new Button();
if (e.Item.FindControl("ProductBacklogView1") != null)
{
btn = (Button)e.Item.FindControl("ProductBacklogView1").FindControl("patchBuildButton");
}
else
{
btn = (Button)e.Item.FindControl("pbv").FindControl("patchBuildButton");
}
if (btn != null)
{
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(btn);
}
}
我担心由于转发器的enableviewstate设置为false,因此它实际上并没有为按钮启动OnClick。我有点像菜鸟,所以我不确定发生了什么。任何帮助获取ProductBacklogView控件内的按钮都会有所帮助。 控件的标记是......
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProductBacklogView.ascx.cs" Inherits="ScrumDashboard.ui.ProductBacklogView" %>
<%@ Register Src="~/ui/ProductBacklogMenu.ascx" TagName="ProductBacklogMenu" TagPrefix="UC" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<a id="<%="PBI_" + PB.Id.ToString()%>" />
<div id="pbMenu" class="ContextMenuPanel" style="display: none" runat="server">
<UC:ProductBacklogMenu PB=<%# PB %> runat="server"></UC:ProductBacklogMenu>
</div>
<ajaxToolkit:DropDownExtender runat="server" ID="DDE"
TargetControlID="pbView"
DropDownControlID="pbMenu" />
<div id="pbView" class="ProductBacklogTitle" runat="server">
<a class="<%#PB.State=="Done" ? "DoneProductBacklog" : "NotDoneProductBacklog" %>" href="javascript: openWorkItemWithRefresh(<%#PB.Id%>, <%#PB.RevisionId%>, <%#IsTFS2012%>)"><%#PB.Title%></a> (<%#PB.Id%>)
</div>
<% if(!String.IsNullOrEmpty(PB.Team) && String.IsNullOrEmpty(CurrentTeam)){%>
<div class="ProductBacklogText">Team:</div><div class="ProductBacklogText2"><%=PB.Team%></div>
<%}%>
<div class="ProductBacklogText">State:</div><div class="ProductBacklogText2"><%=PB.State%></div>
<div class="ProductBacklogText">Priority:</div><div class="ProductBacklogText2"><%=PB.BusinessPriority %></div>
<div class="ProductBacklogText">Effort:</div><div class="ProductBacklogText2"><%=PB.EstimatedEffort %></div>
<div class="ProductBacklogText">Work:</div><div class="ProductBacklogText2"><%=PB.All.CompletedWorkTotal + " of " + PB.All.WorkTotal + " (" + PB.All.CompletedWorkPercentage.ToString("##0") + "%)" + RenderWorkBreakdownChevrons()%></div>
<asp:Button id="patchBuildButton" Text="Build Patch" runat="server" OnClick="patchBuildButton_click" /><br />
<%=RenderWorkBreakdownInformation()%>
<div class="<%#ShowEstimateInformation ? "ProductBacklogText" : "ProductBacklogText invisible"%>">Est:</div><div class="<%#ShowEstimateInformation ? "ProductBacklogText2" : "ProductBacklogText2 invisible"%>"><%# RenderEstimate() %></div>
<%=RenderDefectInfo()%>
<%if(PB.SprintNumber!=CurrentSprint){%>
<div class="FromAnotherSprint">
<%=PB.SprintName%>
</div>
<%}%>