I have a UserControl that I declare programmaticall y as follows:
Dim userctrl as New rightside_porta l()
The codebehind file for this UserControl looks like the following:
Partial Public Class rightside_porta l : Inherits System.Web.UI.U serControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
Const renewurl As String = "http://www.renewingsit e.com/"
Me.lblExpiresOn .Text = String.Format(" IMPORTANT<br/>Your account is set to
expire {0}. To renew your membership, please ", "EXPIRATIONDATE ")
Me.lnkRenew.Nav igateUrl = renewurl
Me.lnkSaveToday .NavigateUrl = renewurl
End Sub
End Class
However, I receive the following error when I run the application:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
AFBE.rightside_ portal.Page_Loa d(Object sender, EventArgs e) +59
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.C ontrol.LoadRecu rsive() +131
System.Web.UI.C ontrol.LoadRecu rsive() +131
System.Web.UI.C ontrol.LoadRecu rsive() +131
System.Web.UI.C ontrol.LoadRecu rsive() +131
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.507 27.42; ASP.NET
Version:2.0.507 27.210
I am pretty sure the problem has something to do with the fact that I am
declaring the UserControl in my codebehind rather than my *.aspx file, but I
am not quite sure what I need to do differently. If anyone can help me, I
would appreciate it. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/