Reputation: 107
I used an UpdatePanel to prevent all page reload when clicking a button. But when I use it the upload file doesn't work and have null filled. When I removed the update panel it worked well. So how can I solve this issue?
<asp:UpdatePanel ID="UPAddPost" runat="server">
<ContentTemplate>
<fieldset style="width: 498px; text-align: right; padding: 5px; direction: rtl;">
<legend>GO</legend>
<div class="add-post">
<textarea class="textarea" name="" cols="3" rows="3" runat="server" id="txpost"></textarea>
<asp:RequiredFieldValidator ID="RVAddPost" runat="server" ForeColor="Red" ErrorMessage="*"
ControlToValidate="txpost" ValidationGroup="AddUserPost">*</asp:RequiredFieldValidator>
</div>
<div class="add-post-control">
<div class="post">
<asp:Button Text="go" runat="server" ID="btAddPost" OnClick="btAddPost_Click" ValidationGroup="AddUserPost" />
</div>
<div class="fileUpload btn btn-primary">
<div class="fileUpload btn btn-primary">
<span>
<img src="res/images/img.png" width="38" height="27" /></span>
<input type="file" runat="server" class="upload" id="FUFile" />
</div>
</div>
</div>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btAddPost" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Upvotes: 0
Views: 103
Reputation: 50728
This will never work due to a restriction on the browser (see this SO answer). You have to use the AJAXControlToolkit AjaxFileUpload control, which was meant to handle this. You can also use uploadify, or several other utilities (there are controls for this in products like Telerik, etc.)
Upvotes: 1