asp.net:
It looks as if InnerPage never gets initialized, maybe create a new instance
in the New constructor...
Public Class SomeControl
Inherits Web.UI.WebControls.WebControl
Private InnerPage As Control
Private pAscxFile As String
Private MaTable As HtmlTable
Public Sub New()
InnerPage = New Control()
MaTable = New HtmlTable()
Dim MaLigne As New HtmlTableRow()
Dim MaCellule As New HtmlTableCell()
MaLigne.Cells.Add(MaCellule)
MaTable.Rows.Add(MaLigne)
Me.Controls.Add(MaTable)
End Sub
End Class
[quoted text, click to view] "Quentin" <Quentin.Casasnovas@wanadoo.Fr> wrote in message
news:e3xAoI6VDHA.1204@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> I got a Solution, containing two projects, a project of classes, and a web
> project. The two projects directories are not located in the same place
> (directory ?). Into my project of classes i've got a class.vb file where i
> made a very class :
>
> ------ class.vb-------
> Public Class Fenetre : inherits WebControl
>
> Private InnerPage As Control
> Private pAscxFile As String
> Private MaTable As New HtmlTable
>
> Public Sub New()
> Dim MaLigne As New HtmlTableRow
> Dim MaCellule As New HtmlTableCell
>
> MaLigne.Cells.Add(MaCellule)
> MaTable.Rows.Add(MaLigne)
> Me.Controls.Add(MaTable)
> End Sub
>
> Public Property AscxFile() As String
> Get
> AscxFile = pAscxFile
> End Get
> Set (ByVal Value As String)
> pAscxFile = Value
> Ajout_InnerPage(pAscxFile)
> End Set
> End Property
>
> Public Sub Ajout_InnerPage(ByVal AscxPath As String)
> Dim ControlAscx As Control = Me.Page.LoadControl(AscxPath)
> Me.MaTable.Rows(0).Cells(0).Controls.Add(ControlAscx)
> End Sub
>
> End Class
> ---------------------
>
> After that i'm going in an *.aspx of my web project, in the tool box i
chose
> to add elements, i choose my *.dll in the directory of my project of
> classes. Now that my Control is in the tool box, i drag and drop it into
my
> page and for now there isn't any problem... The problem shows up when i
try
> to change the AscxFile property as to add a usercontrol into my control...
i
> put in the porperty the file path of an ascx file that is in the web
project
> directory, for example "test.ascx" and after validating my property i got
> this error : "the object reference is not defined at the "instance" of an
> object" on the line ----->
> Me.maTable.Rows(0).Cells(0).Controls.Add(InnerPage)
>
> Here is the tree of my solution :
>
> Solution
> ---Web Project
> ------Index.aspx
> ------Test.ascx
> ---Project of classes
> ------class.vb
> ------bin
> ---------maclasse.dll
>
> i know it's a huge message but i've been searching the answer for 2 days
now
> and i prefer send the maximum precisions as i can...
>
> Thanks for evrybody who's red this till the end, and a huge big giant
thank
> to all people who's gonna help me :)
>
> Scuse my bad english :-S
>
>