473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Can't Figure Out What is Wrong

I am getting the following error whe I run this upload process. Code is
below - error points to the
lblInfo.Text = "Failed uploading file"

line? The upload runs fine and the file is properly uploaded to the
"scores" directory? What is it complaining about?
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

=================== code =======================
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpload.Click

If Not (uploadedfile.PostedFile Is Nothing) Then

Try

Dim postedFile = uploadedfile.PostedFile

filename = Path.GetFileName(postedFile.FileName)

Dim contentType As String = postedFile.ContentType

Dim contentLength As Integer = postedFile.ContentLength

uploadedfile.PostedFile.SaveAs(Server.MapPath("./scores/" & filename))

'postedFile.SaveAs("./scores/" & filename)

lblInfo.Text = "Upload Successful!"

lblInfo.Visible = True

btnSave.Visible = True

Catch ex As Exception

lblInfo.Text = "Failed uploading file"

lblInfo.Visible = True

End Try

End If
End Sub
Nov 19 '05 #1
6 1375
On Sun, 27 Feb 2005 10:59:12 -0700, "Wayne Wengert"
<wa***************@wengert.com> wrote:

I know this may be a silly question, but you do have the

<ASP:Label id="lblInfo" ....../>

in your HTML code for the page ? I don't recall the exact error
that'd be reported if you didn't but trying to call the Text property
of the Label object before instantiating it would give this error.


Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 19 '05 #2
Wayne.. i'd say since u are getting :-
the error:-
System.NullReferenceException: Object reference not set
to an instance of an object.

Its possible Michael is right that u are not using lblInfo or something
related
Hope it helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3
Michael;

Yes, lblInfo is there and is used without problem in some other Subs

Wayne

"Michael H" <Mi*****@Strawberry.Gatorade.yum> wrote in message
news:fb********************************@4ax.com...
On Sun, 27 Feb 2005 10:59:12 -0700, "Wayne Wengert"
<wa***************@wengert.com> wrote:

I know this may be a silly question, but you do have the

<ASP:Label id="lblInfo" ....../>

in your HTML code for the page ? I don't recall the exact error
that'd be reported if you didn't but trying to call the Text property
of the Label object before instantiating it would give this error.


Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 19 '05 #4
On Sun, 27 Feb 2005 18:39:09 -0700, "Wayne Wengert"
<wa***************@wengert.com> wrote:
Michael;

Yes, lblInfo is there and is used without problem in some other Subs

Wayne


Wayne,

Ok, does the problem go away if you just omit the
lblInfo.Text = "Failed uploading file"
lblInfo.Visible = True
?

It appears that you're stating that the lblInfo object is not null
before the catch block but null within it; if I'm understand you
correctly.
Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 19 '05 #5
The suggestions you all were giving me pointed to a problem with that label
(even though VSNET IDE saw it as far as autocomplete tasks?). Anyway, I
deleted the html code defining that label, saved and closed the solution. I
then re-opened the solution, used the toolbox to add the label back with the
same name and now it appears to work?

I have no idea what was wrong!

Thanks for all the suggestions.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I am getting the following error whe I run this upload process. Code is
below - error points to the
lblInfo.Text = "Failed uploading file"

line? The upload runs fine and the file is properly uploaded to the
"scores" directory? What is it complaining about?
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

=================== code =======================
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpload.Click

If Not (uploadedfile.PostedFile Is Nothing) Then

Try

Dim postedFile = uploadedfile.PostedFile

filename = Path.GetFileName(postedFile.FileName)

Dim contentType As String = postedFile.ContentType

Dim contentLength As Integer = postedFile.ContentLength

uploadedfile.PostedFile.SaveAs(Server.MapPath("./scores/" & filename))

'postedFile.SaveAs("./scores/" & filename)

lblInfo.Text = "Upload Successful!"

lblInfo.Visible = True

btnSave.Visible = True

Catch ex As Exception

lblInfo.Text = "Failed uploading file"

lblInfo.Visible = True

End Try

End If
End Sub

Nov 19 '05 #6
On Sun, 27 Feb 2005 23:37:04 -0700, "Wayne Wengert"
<wa***************@wengert.com> wrote:
The suggestions you all were giving me pointed to a problem with that label
(even though VSNET IDE saw it as far as autocomplete tasks?). Anyway, I
deleted the html code defining that label, saved and closed the solution. I
then re-opened the solution, used the toolbox to add the label back with the
same name and now it appears to work?

I have no idea what was wrong!

Thanks for all the suggestions.

Wayne

One of my thoughts was that you may have had a type-oh somewhere
pertaining to the Label but it's impossible to tell from my chair w/o
having saw your entire code. The good thing is that you got it to
work, but it'd be very nice to know what was crashing your app. to
avoid future problems.

Ciao,
Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: marco | last post by:
the problem: I use a typedef inside a class template, than I use this type (dim_v<N1>::Type) to define the argument of a template function f but when I call this function from main, the compiler...
1
by: Rinus Luijmes | last post by:
I'm collection GPS-waypoints in the GPX-format (http://www.topografix.com/gpx.asp) which is XML. This example file validates in XMLSpy: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>...
3
by: john | last post by:
I don't want to know what the CPU utilization is right now. I want to get the average utilization over the last, for example, hour. So I came up with a method where I would get a Process object...
4
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this...
8
by: nobrow | last post by:
Okay ... Im out of practice. Is it not possible to have a 2D array where each column is of a different type, say an int and a struct*? The following seg faults for me and I cant figure out what I...
0
by: Steve | last post by:
I have a gridview which uses an objectdatasource for its select and delete. The delete command uses the function below. The delete itself works but the extra logic which requires parameters...
9
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. For a...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
15
by: E-Dot | last post by:
I am trying to write a program which asks the user to enter a number in the interval , the program then gives the natural logarithm of that number, using the series for log(x+1)... Here is what...
22
risk32
by: risk32 | last post by:
Hi all. I'm having a little bit of a problem with the new Date() object in JS. I can get it to work just fine, however, I don't want the .getDay() to return a number. I started to create an array...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.