Trouble with Customer Controls

aminosgrp

New Member
Ok I have these three files below<BR><BR>view.aspx<BR><%@ Register TagPrefix="view" TagName="product" src=http://aspmessageboard.com/archive/index.php/"/view.ascx" %><BR><BR><html><BR><body><BR> <view:product runat="server" id="viewProd" /><BR></body><BR></html><BR><BR>view.ascx<BR><%@ Control Language="VB" Inherits="CodeBehindView" SRC="CodeBehindView.vb"%><BR><asp:label id="lblTitle" runat="server" /><BR><BR>CodeBehindView.vb<BR>Imports System<BR>Imports System.Web<BR>Imports System.Web.UI<BR>Imports System.Web.UI.WebControls<BR><BR>Public Class CodeBehindView : Inherits UserControl<BR> pulbic lblTitle as label<BR>Sub Page_Load(obj as object, e as eventArgs)<BR> lblTitle.Text = "Test"<BR>End Sub<BR>End Class<BR><BR>I'm getting a <BR>System.NullReferenceException: Object reference not set to an <BR>instance of an object. <BR>error on the line <BR> lblTitle.Text ="Test" <BR>Is there something speical I need to do so I can set the properties of the label in the custom control?<BR><BR>Thanks!Try declaring lblTitle in your codebehind as protected<BR><BR>protected lblTitle as LabelDoh! Such an easy solution but it would of taken me ages to find. Thanks a lot.
 
Back
Top