我有一個UpdatePanel,它有一個上傳控件和一個上傳按鈕。該按鈕被設置爲觸發器,但該按鈕的事件處理程序無法在第一個回發中執行。ASP.NET - 用PostBack觸發器的FileUpload
我的ASPX代碼:
<asp:UpdatePanel ID="updPages" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="tabs">
<ul>
<li><asp:LinkButton ID="lnkContentsPages" runat="server" OnClick="updateContents" CommandArgument="pages">Pages</asp:LinkButton></li>
<%-- these tabs change the ActiveViewIndex to show a different UserControl --%>
<li><asp:LinkButton ID="lnkContentsImages" runat="server" OnClick="updateContents" CommandArgument="images">Images</asp:LinkButton></li>
</ul>
<div class="tabbedContent">
<asp:MultiView runat="server" ID="mltContentsInner" ActiveViewIndex="0">
<asp:View ID="viwContentsImages" runat="server">
// ajax usercontrol for a list of images - works fine with ajax
<fieldset>
<legend>Upload New</legend>
<div class="formRow">
<asp:Label ID="lblFile" runat="server" Text="Filename" AssociatedControlID="uplFile" />
<asp:FileUpload ID="uplFile" runat="server" />
</div>
<div class="formRow">
<asp:Label ID="lblImageDescription" runat="server" Text="Description" AssociatedControlID="txtImageDescription" />
<asp:TextBox runat="server" ID="txtImageDescription" />
</div>
<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="c3button btnUpload" CausesValidation="false" OnClick="btnUpload_Click" />
</fieldset>
</asp:View>
<asp:View ID="viwContentsPages" runat="server">
// ajax usercontrol - works fine with ajax
</asp:View>
</asp:MultiView>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
</asp:UpdatePanel>
按鈕的作品沒有失敗第二次及以後,只是沒有第一。這有什麼理由嗎?
解決此問題有什麼好運氣? – Jonathan 2010-05-12 12:53:50
不幸的不是。行爲似乎是間歇性的,這是最糟糕的錯誤類型。 – Echilon 2010-05-14 13:04:32
你可以添加服務器端代碼嗎? – chapluck 2010-05-26 12:21:27