473,505 Members | 13,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ascx... again :'(

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(ControlAs cx)
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
Nov 17 '05 #1
2 1812
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
"Quentin" <Qu****************@wanadoo.Fr> wrote in message
news:e3**************@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(ControlAs cx)
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

Nov 17 '05 #2
I've just tried your code and it doesn't work... thank you for your response
:)
"alien2_51" <da********@n.o.s.p.a.m.monacocoach.com> a écrit dans le message
de news: #8**************@TK2MSFTNGP10.phx.gbl...
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
"Quentin" <Qu****************@wanadoo.Fr> wrote in message
news:e3**************@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(ControlAs cx)
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


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6507
by: Quentin | last post by:
I need to import an *;ascx, as an object, in my class, that is in myclass.vb. How can i do ? i saw the method LoadControl but i can't use it, or maybe i did wrong, if could help me it would be very...
1
1758
by: Jouni Heikniemi | last post by:
Hi, This has been asked before, in <http://groups.google.fi/groups? selm=ureiu7b04kv839%40corp.supernews.com> for example; however, I haven't found any real answers, so I'll post this with some...
2
7210
by: sanju | last post by:
hi there i am trying to fire an button event in ascx file which interacts with database ,my problem is " i am calling ascx file wiht a button click dynamically when user needs to update database...
5
3034
by: djscratchnsniffing | last post by:
i know you can access an ascx's properties/methods from an aspx file. Let's say you have an aspx file with two code-behind files(ascx files). Can you access one of the ascx file's...
2
1612
by: Henry Sun | last post by:
Hi all, New to ASP.NET and this Newsgroup. recently I saw some major websites use ascx page as their index page (e.g. index.ascx?ProductId=blah). I did a little bit rearch but I still couldn't...
0
2146
by: mschep | last post by:
Hi, I built an assembly with a set of user controls. This can be done with the Visual Studio 2005 Deployment Project: building and merging for example all your aspx and ascx in one dll (lets...
0
1415
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have an ascx file that dynamically loads other ascx files. each of these ascx files need to perform client callback functions. It seems that when i try and break out all the javascript code into...
0
2924
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
1895
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.