Solved

FIle Upload VB.NET

Posted on 2011-03-09
6
922 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

830 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