ascx... again :'(

Q

Quentin

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
 
A

alien2_51

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top