Hi,
We have a Webform on which we have multiple controls(ListBox,TextBox, Ajax HTML Editor,FileUploader).
We have used Ajax Update Panel to stop page refresh(Postback)) because we are copying Items from 1st Listbox to another on button click. We are sending an email with attachment(FileUploader) on another button click.
The issue is File Uploader does not work inside Update Panel. It doesnt not remember the path.
Is there a way to make it work?
Thanks
Cien
Loading
Pankaj SinghPosted Nov 14, 2009, 1:04 AM
Really this help me.
keshav singhPosted Nov 14, 2009, 12:54 AM
All file upload controls does not working in any ajax update panel and upload control needs to full page postback. This means if your upload control located in an update panel, control does not post the file. If you look to the posted file property of the control, you will see it null. So, the control always have to post full page postback.
To resolve this problem we need to rely upon a standard postback i.e. we need to set the button that is uploading the file to be PostBack trigger instead of AsyncPostBack trigger. This will initiate a normal postback whenever we click the upload button and it is possible to upload the file.
You need to create a PostBackTrigger for the button which should initiate postback like as follows.<Triggers>
<asp:PostBackTrigger ControlID="Upload" />
Triggers>
For Example:
InLine Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Pagetitle>
head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<table width="50%" cellpadding="2" cellspacing="0">
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Upload" runat="server" Text="Upload" OnClick="Upload_Click" /><br />
<asp:Image ID="NormalImage" runat="server" />ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Upload" />
Triggers>
asp:UpdatePanel>
td>
tr>
table>
div>
form>
body>
html>
or you can see for more details:
http://www.c-sharpcorner.com/UploadFile/prathore/FileUpload04292009022804AM/FileUpload.aspx
if this helps you
then mark as answer