Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET - FileUpload with PostBack Trigger
    primarykey
    data
    text
    <p>I have an UpdatePanel which has an upload control and a button to upload. The button is set as a trigger, but the event handler for the button fails to execute on the first PostBack. </p> <p>My ASPX code is:</p> <pre><code>&lt;asp:UpdatePanel ID="updPages" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;div class="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;asp:LinkButton ID="lnkContentsPages" runat="server" OnClick="updateContents" CommandArgument="pages"&gt;Pages&lt;/asp:LinkButton&gt;&lt;/li&gt; &lt;%-- these tabs change the ActiveViewIndex to show a different UserControl --%&gt; &lt;li&gt;&lt;asp:LinkButton ID="lnkContentsImages" runat="server" OnClick="updateContents" CommandArgument="images"&gt;Images&lt;/asp:LinkButton&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="tabbedContent"&gt; &lt;asp:MultiView runat="server" ID="mltContentsInner" ActiveViewIndex="0"&gt; &lt;asp:View ID="viwContentsImages" runat="server"&gt; // ajax usercontrol for a list of images - works fine with ajax &lt;fieldset&gt; &lt;legend&gt;Upload New&lt;/legend&gt; &lt;div class="formRow"&gt; &lt;asp:Label ID="lblFile" runat="server" Text="Filename" AssociatedControlID="uplFile" /&gt; &lt;asp:FileUpload ID="uplFile" runat="server" /&gt; &lt;/div&gt; &lt;div class="formRow"&gt; &lt;asp:Label ID="lblImageDescription" runat="server" Text="Description" AssociatedControlID="txtImageDescription" /&gt; &lt;asp:TextBox runat="server" ID="txtImageDescription" /&gt; &lt;/div&gt; &lt;asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="c3button btnUpload" CausesValidation="false" OnClick="btnUpload_Click" /&gt; &lt;/fieldset&gt; &lt;/asp:View&gt; &lt;asp:View ID="viwContentsPages" runat="server"&gt; // ajax usercontrol - works fine with ajax &lt;/asp:View&gt; &lt;/asp:MultiView&gt; &lt;/div&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:PostBackTrigger ControlID="btnUpload" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>The button works without fail on the second and subsequent times, just not the first. Is there any reason for this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload