Solved

FIle Upload VB.NET

Posted on 2011-03-09
6
920 Views
Last Modified: 2013-11-08
I am trying to use the Ajax AsyncFileUpload.  Once I select the file I get the following error.

Microsoft JScript runtime error: 'lblStatus' is undefined.
Here is my html

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ MasterType virtualpath="~/MasterPages/Speaker.master" %>

the control

<asp:UpdatePanel ID="pnlUpload" runat="server">
		<ContentTemplate>
			<table>
				<cc1:AsyncFileUpload ID="fuSlides" Width="400px" runat="server"
				OnClientUploadError="uploadError" 
				OnClientUploadStarted="StartUpload" 
				OnClientUploadComplete="UploadComplete" 
				CompleteBackColor="Lime"
				UploaderStyle="Modern" 
				ErrorBackColor="Red" 
				onuploadedcomplete="fuSlides_UploadedComplete" 
				UploadingBackColor="#66CCFF" />
			</table>
			<br>
			</br>
			<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
		</ContentTemplate>	
	</asp:UpdatePanel>

the javascript

 <script type="text/javascript" language="javascript">
	     function uploadError(sender, args) {
	         alert("[" + lblStatus + "]"); return false;
	         document.getElementById('lblStatus').innerHTML = args.get_errorMessage();
		 }
	     function StartUpload(sender, args) {
	         alert("[" + fuSlides + "]"); return false;
			 var filename = args.get_fileName();
			 var filext = filename.substring(filename.lastIndexOf(".") + 1);
			 if (filext == "doc" || filext == "docx" || filext == "pdf" || filext == "pages" || filext == "pptx" || filext == "ppt") {
				 return true;
			 }
			 else {
				 var err = new Error();
				 err.name = 'My API Input Error';
				 err.message = 'Only .ppt, .pptx, .doc, .docx, or .pdf  files';
				 throw (err);

				 return false;
			 }
		 }
	    function UploadComplete(sender, args) {;
			var filename = args.get_fileName();
			var contentType = args.get_contentType();
			var text = "Size of " + filename + " is " + args.get_length() + " bytes";
			if (contentType.length > 0) {
				text += " and content type is '" + contentType + "'.";
			}
		}
</script>

Open in new window

0
Comment
Question by:triplebd69
  • 4
  • 2
6 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35086750
Instead of:
document.getElementById('lblStatus').innerHTML = args.get_errorMessage();

Open in new window

Try:
document.getElementById('<%= lblStatus.ClientID %>').innerHTML = args.get_errorMessage();

Open in new window

0
 

Author Comment

by:triplebd69
ID: 35086920
Thanks for the comment.  That helped some.

As soon as I press open on the browse window, to open a file I get -
 "Unknown server error"

When I click ok I get
"Error: ASP.NET Ajax client-side framework failed to load."

Then
"Sys unknown"
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35087047
What does "fuSlides_UploadedComplete" do?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:triplebd69
ID: 35087230
Right now not much, I have a break point set on it and it never hits it.

 Protected Sub fuSlides_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles fuSlides.UploadedComplete

        If e.state = AjaxControlToolkit.AsyncFileUploadState.Success Then
            lblStatus.Text = "Uploaded"
        End If

    End Sub
0
 

Accepted Solution

by:
triplebd69 earned 0 total points
ID: 35087391
Turns out that this site is running on 2.0 framework, so I don't think that I can get this control to work on it, I believe that it needs the 3.5 framework or higher.
0
 

Author Closing Comment

by:triplebd69
ID: 35135916
Wrong framework
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question