Quote:
|
quote: I'm having the same problem with the usercontrol not being instantiated right away. Has anyone found a resolution for this?
|
I also am also having the same issue with a user control not being instantiated.
Symptoms:
I included a user control in the page:
Code:
<%@ Register TagPrefix="uc1" TagName="countControl" Src="countControl.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Count.aspx.vb" Inherits="InfraWare.Count"%>
<body>
<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="lblClicked" runat="server">Counter not clicked</asp:Label></P>
<P>
<uc1:countControl id="counter" runat="server"></uc1:countControl></P>
</form>
</body>
</HTML>
And then attempted to use it in the "codebehind":
Code:
Private WithEvents counter As countControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
lblClicked.Text = counter.ID
lblClicked.Text += CType(counter.Number, String)
End Sub
This gives the error: "Object reference not set to an instance of an object. " when I attempt to access the counter.
I beleive that planoie is right:
Quote:
|
quote: I trust there is an instance of this user control in the markup for this page. That's where the control is instantiated, so you don't need the New keyword in the codebehind.
|
But microsoft doesn't seem to agree... does anyone know what is going on here?