ID为';btUnpload';在UpdatePanel中找不到触发器的';pnlUpdate'
本文关键字:找不到 触发器 pnlUpdate btUnpload ID UpdatePanel | 更新日期: 2023-09-27 18:28:12
hi我有一个用户控件,我想把它放在更新面板里,我的代码看起来像这个
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuestionControl.ascx.cs"
Inherits="ProcessFramework.QuestionControl" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
<ContentTemplate>
<asp:DataList ID="QuestionList" runat="server" OnItemDataBound="QuestionList_ItemDataBound"
OnEditCommand="LinkButton1_EditCommand">
<ItemTemplate>
<div class="QuestionObject">
<asp:HiddenField ID="QuestionID" runat="server" Value='<%# Eval("QuestionID") %>' />
<span class="QuestionsLabel">
<h2>
<asp:Label ID="QuestionTextLabel" runat="server" Text='<%# Eval("QuestionText") %>'></asp:Label></h2>
</span>
<asp:Panel ID="LinkPanel" runat="server" Visible='<%# Eval("HasLink") %>' CssClass="QuestionsLink">
<asp:HyperLink runat="server" ID="QuestionLink" Text='<%# Eval("LinkText") %>' Target="_blank"
NavigateUrl='<%# Eval("LinkURI") %>'></asp:HyperLink>
</asp:Panel>
<br />
<asp:Panel ID="ResponseInputPanel" runat="server" Visible="false" CssClass="QuestionsText">
<asp:TextBox runat="server" Text='<%# Eval("Response") %>' TextMode="MultiLine" CssClass="TextArea"
ID="QuestionResponseTextBox">
</asp:TextBox><asp:HtmlEditorExtender ID="HtmlEditorExtender1" TargetControlID="QuestionResponseTextBox"
runat="server" EnableSanitization="false" DisplaySourceTab="true">
<Toolbar>
<asp:Undo />
<asp:Redo />
<asp:Bold />
<asp:Italic />
<asp:Underline />
<asp:StrikeThrough />
<asp:Subscript />
<asp:Superscript />
<asp:JustifyLeft />
<asp:JustifyCenter />
<asp:JustifyRight />
<asp:JustifyFull />
<asp:InsertOrderedList />
<asp:InsertUnorderedList />
<asp:CreateLink />
<asp:UnLink />
<asp:RemoveFormat />
<asp:SelectAll />
<asp:UnSelect />
<asp:Delete />
<asp:BackgroundColorSelector />
<asp:ForeColorSelector />
<asp:FontNameSelector />
<asp:FontSizeSelector />
<asp:Indent />
<asp:Outdent />
<asp:InsertHorizontalRule />
<asp:HorizontalSeparator />
<asp:Cut />
<asp:Copy />
<asp:Paste />
</Toolbar>
</asp:HtmlEditorExtender>
<div class="QuestionActions">
<asp:LinkButton ID="lnkClear" runat="server" Text="Clear" OnCommand="lnkClearA_OnCommand"
CommandArgument='<%# Container.ItemIndex %>' Visible="false">
</asp:LinkButton>
<label>
|</label>
<asp:LinkButton ID="LinkClearAll" runat="server" Text="Preview" OnCommand="lnkClearAllResponse_OnCommand"
CommandArgument='<%# Container.ItemIndex %>' Visible="false">
</asp:LinkButton>
<asp:Panel ID="AttachmentPanel" runat="server" Visible='<%# Eval("HasAttachment") %>'
CssClass="QuestionsAttachment">
<asp:Panel ID="AttachmentPanelUploadSection" runat="server" Visible='<%# (bool.Parse(Eval("IsAttachmentExist").ToString()) == false) %>'>
<asp:Literal ID="AttachFileLabel" runat="server" Text="Attach file (Max 10MB):" /><asp:FileUpload
ID="FileUpload1" runat="server" CssClass="button" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="button" OnCommand="btnUpload_OnCommand"
CommandArgument='<%# Container.ItemIndex %>' />
</asp:Panel>
<asp:Panel ID="AttachmentPanelFileInfoSection" runat="server" Visible='<%# Eval("IsAttachmentExist") %>'>
Attachment:
<asp:Literal ID="AttachementFileName" runat="server" Text='<%# Eval("AttachmentURI") %>'
Visible="true" />
<asp:LinkButton ID="RemoveAttachment" runat="server" CommandArgument='<%# Container.ItemIndex %>'
CssClass="imagelink" OnCommand="lnkRemoveAttachment_OnCommand" ToolTip="Remove"
Height="16px">
</asp:LinkButton>
</asp:Panel>
</asp:Panel>
</div>
</asp:Panel>
<asp:Panel ID="ResponseLabelPanel" runat="server" Visible="true">
<div class="QuestionsResponse">
<asp:Literal ID="ResponseLiteral" runat="server" Text='<%# Eval("Response") %>' />
</div>
<asp:LinkButton ID="LinkEditResponse" runat="server" Text="Edit" OnCommand="lnkEditResponse_OnCommand"
CommandArgument='<%# Container.ItemIndex %>'>
</asp:LinkButton>
<asp:Image ID="AttachmentIcon" runat="server" Visible='<%# (bool.Parse(Eval("IsAttachmentExist").ToString()) == true) %>'
ImageUrl="~/Content/Images/attachment.png" Width="14" Height="14" Style="float: right;
position: relative" />
<asp:LinkButton ID="LinkButton1" ToolTip="Download Attachment" runat="server" CommandName="Edit"
CssClass="linkbutton" Visible='<%# (bool.Parse(Eval("IsAttachmentExist").ToString()) == true) %>'
CommandArgument='<%# Eval("AttachmentURI") %>' Text='<%# Eval("AttachmentURI") %>' />
</asp:Panel>
</div>
</ItemTemplate>
<SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SeparatorTemplate>
<hr style="margin-top: 5px" />
</SeparatorTemplate>
</asp:DataList>
<asp:HiddenField ID="ObjID" runat="server" />
<br />
<table style="width: 200px;" align="right">
<tr>
<td>
<asp:Button ID="btnCancel" runat="server" CssClass="btn" OnClick="btnCancel_Click"
Text="Cancel" Visible="false" />
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" CssClass="btn" OnClick="btnSubmit_Click"
Text="Save" Visible="false" />
</td>
</tr>
</table>
<br />
<br />
<hr />
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" HorizontalAlign="center"
OnPageChanged="AspNetPager1_PageChanged" PageSize="1" ShowPageIndexBox="Never"
AlwaysShowFirstLastPageNumber="true" PagingButtonSpacing="5" UrlPaging="false"
AlwaysShow="false" CssClass="paginator" CurrentPageButtonClass="cpb">
</webdiyer:AspNetPager>
</ContentTemplate>
由于我将文件上传控件放置在更新面板内,我还设置了post-back触发器,控件id为我正在上传数据的按钮的id。这个问题是因为我把按钮放在了一个控件里吗?有人能帮我解决这个问题吗?
由于我的用户控件在DataList控件内,我对ItemCreated事件执行了以下操作,并且功能运行良好
protected void QuestionList_ItemCreated(Object sender, DataListItemEventArgs e)
{
Control uploadButton = e.Item.FindControl("btnUpload");
Control DownloadLinkButton = e.Item.FindControl("LinkButton1");
if (uploadButton != null)
{
ScriptManager mgr = ScriptManager.GetCurrent(this.Page);
mgr.RegisterPostBackControl(uploadButton);
mgr.RegisterPostBackControl(DownloadLinkButton);
}
}