Asp.net Fileupload Control With Updatepanel

Posted by perfectchourasia-9163 under ASP.NET on 3/15/2012 | Points: 10 | Views : 12725 | Status : [Member] | Replies : 9
Fileupload not working i m trying to so loader image before save file in folder.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="filupload.aspx.cs" Inherits="filupload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">

<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" id="Panel">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Upload" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="upd" runat=server>
<ProgressTemplate><img src="images/preloader_S.gif" /></ProgressTemplate>
</asp:UpdateProgress>
<asp:Label ID=status runat=server></asp:Label>
</div>
</form>
</body>
</html>





{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(10000);
if (FileUpload1.HasFile)
{
try
{
string filename = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/downloadsan/") + filename);
status.Text = "Uploaded"+" " +filename;
}
catch (Exception ex)
{
status.Text = "failed";
}
}
}
}

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/



Responses

Posted by: Sksamantaray on: 3/15/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Sandeep,
Follow this.
http://www.codeproject.com/Articles/16945/Simple-AJAX-File-Upload

Thanks,
Sanjay

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
hi

see this link it will help

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx

Thanks

R D Patel

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx

For this i have to use ajxtoolkit so if possible without it.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/15/2012 [Member] Silver | Points: 25

Up
0
Down
The article i refereed above does not require AjaxControlToolkit

Thanks,
Sanjay

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
Yes Sir you are right but in that page getting refresh.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/15/2012 [Member] Silver | Points: 25

Up
0
Down
Try to keep fileupload control in one panel , rest all controls in another panel.
Refresh the panel which holds the fileupload control.

Thanks,
Sanjay

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

then you should use jQuery or div

see this link

http://stackoverflow.com/questions/7088299/how-to-show-gif-image-while-uploading-using-jquery-form-plugin-in-asp-net-mvc


Thanks

R D Patel

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

try trigger event on file upload controls update panel
in that trigger for progress image

Thanks



R D Patel

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vinay13mar on: 10/14/2012 [Member] Starter | Points: 25

Up
0
Down
check the link
http://dotnetpools.com/Article/ArticleDetiail/?articleId=5&title=Fileupload%20Control%20In%20Asp.net

perfectchourasia-9163, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response