Solved

FIle Upload VB.NET

Posted on 2011-03-09
6
918 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
Comment Utility
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
Comment Utility
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
Comment Utility
What does "fuSlides_UploadedComplete" do?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:triplebd69
Comment Utility
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
Comment Utility
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
Comment Utility
Wrong framework
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now