asyncfileupload in Master page concept

Posted by Rohithrs under ASP.NET AJAX on 2/9/2011 | Points: 10 | Views : 4545 | Status : [Member] | Replies : 6
Hi,
i am practicing Ajax control, In that if asyncfileupload control used in master page concept, error accurs "file upload error".
but normally with out master page if i used its working fine.
below code in Fileupload.aspx :

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" >
function uploadComplete(sender) {
$get("<%=lblMsg.ClientID%>").style.color = "green";
$get("<%=lblMsg.ClientID%>").innerHTML = "File upload successfully";
}
function uploadError(sender) {
$get("<%=lblMsg.ClientID%>").style.color = "red";
$get("<%=lblMsg.ClientID%>").innerHTML = "File upload failed.";
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
OnUploadedComplete="AsyncFileUpload1_UploadedComplete"
ThrobberID="imgLoader" UploaderStyle="Modern"
OnClientUploadComplete="uploadComplete"
OnClientUploadError="uploadError"
onuploadedfileerror="AsyncFileUpload1_UploadedFileError" />

<asp:Image ID="imgLoader" runat="server" ImageUrl="~/Images/loader.gif" />
<br />
<asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
</asp:Content>

Fileupload.aspx.cs :
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

AsyncFileUpload1.SaveAs(Server.MapPath("FileUpload/") + filename);

}




Responses

Posted by: Karthikanbarasan on: 2/9/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Can yoy Post the complete error on what u get and in which place the error comes...

Thanks
Karthik
www.f5Debug.net

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rohithrs on: 2/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

If i run, AsyncFileUpload1_UploadedComplete event not firing. instead i going to function uploadError in javascript directly
and display message "File upload failed"


thanks,
Rohith

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/9/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Solution:

In your code,

<ajaxToolkit:AsyncFileUpload />


Add this,

<ajaxToolkit:AsyncFileUpload  ClientIDMode="AutoID" />


Then try and please share your feedback...

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rohithrs on: 2/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

i find same answer..... its working


thanks,
Rohith

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/9/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
That's nice,

Please Mark s Answer if your query got resolved.

Thanks :)

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/9/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Please post the solution which is working for you... so that others can also understand

Thanks
Karthik
www.f5Debug.net

Rohithrs, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response