.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!

Download and Activate to enter!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Download to Enter | Contest Rules

Learn More!

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 12 votes, 3.17 average. Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 18th, 2005, 08:34 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 17 m 2 sec
Reputation Power: 12
Common causes of: Object reference not set to an instance of an object error

(mods, you might want to make this a sticky)

Considering the large number of "Object reference not set to an instance of an object" errors abound, I figured its my "public duty" to give the main reasons, and thus... reduce the number of superflous threads created on the matter:

Cause one:

Not declaring variables!

Yes, I know it sounds obvious, but MAKE SURE that you've explicity declared the variable, and don't forget to use the appropriate scope!

One common mistayke is when working with Codebehind Classes, consider:

XHTML / Tags:
Code:
 
<body>
<asp:Literal id="litOne" runat="server" />
</body>
 


ASP.Net Codebehind Class
Code:
Public Class PageOne
Inherits System.Web.UI.Page
 
Dim strHello As String
 
Sub Page_Load(ByVal e As System.EventArgs) Handles MyBase.Load
	strHello = "Hello!"
	litOne.Text = strHello
End Sub
 
End Class


Remember! Codebehinds arn't handled the same way as inline/<script> pages!

You need to declare EVERY control you want to interact with in the codebehind class

...Do this just after the Inherits statement:

Code:
Public Class PageOne
Inherits System.Web.UI.Page
 
Protected WithEvents litOne As System.Web.UI.WebControls.Literal
 
...


Personally, I use "Protected WithEvents" as its the most flexible and "protects" the object, feel free to use other scopes and attributes as you see fit.

Cause 2: Bad scoping!

Indeed...

One common cause is this:
Code:
Sub Page_Load(ByVal e As System.EventArgs) Handles MyBase.Load
 
	Private strHello As String
 
End Sub
 
Sub Button1_Click(ByVal e As System.EventArgs) Handles Button1.Click
 
	strHello = "Hello!"
 
End Sub


This won't work because strHello is accessible only by Sub Page_Load

Bad inits/constructs
Remember, some classes have constuctors

Consider DirectoryInfo:

Code:
Sub Page_Load() ....
 
Dim dirInfo As System.IO.DirectoryInfo
 
dirInfo.GetDirectory("C:\")
 
End Sub


In the above example, we've only defined dirInfo *AS* a DirectoryInfo class, we haven't actually created it

So we need to do this instead:

Code:
Sub Page_Load() ....
 
Dim dirInfo As System.IO.DirectoryInfo
 
dirInfo = New System.IO.DirectoryInfo("C:\")
 
End Sub


That should do it....

Remember, ALWAYS refer to the MSDN Library when enquiring about classes and their initilisation (sp?) methods.... why trust some "1337 script kiddie!" site when you've got the official reference at http://www.msdn.com ? Or better yet, get the compiled version on CD, don't need to worry about long download times or the constant "was this article of any use to you?" screen.

HTH
-1337_d00d

(and yes, I'm aware of the "mistayke" thing, it was supposed to be ironic, but clearly the humour is lost on you)
Comments on this post
BigGwyn agrees!
medialint agrees!

Reply With Quote
  #2  
Old January 18th, 2005, 04:19 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
Thumbs up

very nice job, dude... I see you really got into it, eh?
we already have about 5 stickies in this forum, I'll consult with the others moderators and we'll see if there is room for another one... this might as well be attached to existing sticky tutorial.
anyways, thanks - this would probably going to be very useful information.

Reply With Quote
  #3  
Old January 18th, 2005, 06:08 PM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 17 m 2 sec
Reputation Power: 12
"Just doing my part"

...I figured I needed to get back into the mod's good books after flaming all the newbs for a while last week

Reply With Quote
  #4  
Old January 19th, 2005, 03:31 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
lol
you didn't flame anyone, and even if you did it was justified as they had non standard code! *shudder*
well, as you see this thread has been stuck already, now let's hope ppl will read it before posting problems of that kind.

Reply With Quote
  #5  
Old January 19th, 2005, 08:17 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 17 m 2 sec
Reputation Power: 12
patience David... patience, climb the ladder...

today... sticky forum topics

tomorrow... THE WORLD!! muwahahahahahhhaha!!!

Reply With Quote
  #6  
Old January 31st, 2005, 04:27 AM
Damnrad24 Damnrad24 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 12 Damnrad24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 48 sec
Reputation Power: 0
Your a pro

Yo dude

You'll probably want to shoot me, but I have this exact error you so passionately talk
about. I have read through your posting but it still hasn't helped me and wonder
if you would mind having a look see. I'm quite a novice in .net but have the coding backround just
need a slight hand.

thanks in advance.

Reply With Quote
  #7  
Old January 31st, 2005, 05:17 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
Quote:
Originally Posted by Damnrad24
Yo dude

You'll probably want to shoot me, but I have this exact error you so passionately talk
about. I have read through your posting but it still hasn't helped me and wonder
if you would mind having a look see. I'm quite a novice in .net but have the coding backround just
need a slight hand.

thanks in advance.

post your problem as new thread and we will see if we can help. in your post, give full details aboout what exactly is wrong, along with relevant code causing errors.

Reply With Quote
  #8  
Old January 31st, 2005, 05:17 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 17 m 2 sec
Reputation Power: 12
I've been having a few different causes of the error recently too, so here's an ammendum:

Not "IDing" user controls!

Consider:

XHTML
Code:
<body>
<MyPrefix:MyControl runat="server" />
</body>


ASP.Net
Code:
 
Protected MyControl As MyNamespace.MySite.MyControl
 
Sub Page_Load() Handles MyBase.Load
MyControl.MyProperty = MyValue
End Sub


...won't work

You need to declare the ID="" attribute:

XHTML
Code:
<body>
<MyPrefix:MyControl id="MyControl" runat="server" />
</body>


HTH

Last edited by 1337_d00d : January 31st, 2005 at 05:29 AM.

Reply With Quote
  #9  
Old January 31st, 2005, 05:19 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
Quote:
Show us your code and I'll take a look (paste it here, I'm sure the mods won't mind... and even then, you can delete it when you're done)

nope, not good idea. this thread is tutorial, it's pointless to make it something else. new problem deserve to be in its own thread.

Reply With Quote
  #10  
Old January 31st, 2005, 05:37 AM
Damnrad24 Damnrad24 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 12 Damnrad24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 48 sec
Reputation Power: 0
Thanks

Quote:
Originally Posted by Shadow Wizard
post your problem as new thread and we will see if we can help. in your post, give full details aboout what exactly is wrong, along with relevant code causing errors.


Will post as a new thread, Look forward to the response! Thank again

Reply With Quote
  #11  
Old July 1st, 2005, 08:23 AM
dotnetdev_03 dotnetdev_03 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 24 dotnetdev_03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 48 sec
Reputation Power: 0
wow good Job!!!

wonderful Job

Reply With Quote
  #12  
Old January 6th, 2006, 06:40 AM
Timo Timo is offline
Timo
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Perth, Australia
Posts: 106 Timo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 22 sec
Reputation Power: 8
Phoenix,

I am truly gratefull for this sticky. I suffered from a cause 3(bad init) for two days before you and your post rescued me. I should have known better. Thanks for getting me out of that mess!

Cheers,
Timo

Reply With Quote
  #13  
Old March 7th, 2007, 02:15 PM
pebkac pebkac is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 1 pebkac User rank is Corporal (100 - 500 Reputation Level)pebkac User rank is Corporal (100 - 500 Reputation Level)pebkac User rank is Corporal (100 - 500 Reputation Level)pebkac User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 sec
Reputation Power: 0
There is another possible solution. I knew there had to be because I had my application working on other computers, but one of them gave me this error (Windows XP).

If you had previously gotten this error:

"Failed to access IIS metabase"

and fixed it with (at the command prompt)

aspnet_regiis -ga IUSR_<computername>
aspnet_regiis -ga IWAM_<computername>

.. and subsequently you get the "Object reference ..." error

then the fix is to run (at the command prompt)

aspnet_regiis -i

I don't know why this problem only occurred on one of my machines. Anyway it seems to be a common problem so I thought I'd post my solution as an alternative. I hope it helps someone.
Comments on this post
Shadow Wizard agrees: thanks for sharing and welcome to the forum.

Reply With Quote
  #14  
Old March 12th, 2007, 09:10 PM
morris_osu morris_osu is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 41 morris_osu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 41 m 9 sec
Reputation Power: 6
Personally, I get this error most often when I'm trying to reference a "buried" control within my codebehind.

For example...

.aspx:
Code:
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <asp:Label ID="testID" runat="server" />
        </ItemTemplate>
    </asp:Repeater>


.aspx.cs
Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        testID.Text = "this won't work";
    }


Pretty sure this is relevant.

Reply With Quote
  #15  
Old March 30th, 2007, 01:21 PM
jmurrayhead jmurrayhead is offline
Moderator
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2004
Location: Reston, VA
Posts: 13,209 jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112187 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 2 Days 10 h 50 m 59 sec
Reputation Power: 1894
Quote:
Originally Posted by morris_osu
Personally, I get this error most often when I'm trying to reference a "buried" control within my codebehind.

For example...

.aspx:
Code:
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <asp:Label ID="testID" runat="server" />
        </ItemTemplate>
    </asp:Repeater>


.aspx.cs
Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        testID.Text = "this won't work";
    }


Pretty sure this is relevant.


Just to add to the above, to reference the "buried" control do such:

vb.net Code:
Original - vb.net Code
  1.  
  2.     Private Sub Page_Load(sender As Object, e As EventArgs)
  3.         Dim testIDtxt As TextBox
  4.         testIDtxt = Repeater1.Controls.(0).FindControl("testID")
  5.         testIDtxt.Text = "this WILL work"
  6.     End Sub


Written in VB, but same concept.
__________________
jmurrayhead

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Common causes of: Object reference not set to an instance of an object error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 



Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap