Ask a Question related to ASP.NET General, Design and Development.
-
Quentin #1
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
Quentin Guest
-
ASP.NET 2.0 BUG with ASCX controls
My application runs fine for a long while then, all of a sudden my it starts getting this error pointing to my ascx control in the call stack ... -
JavaScript Src attrubute in ascx
I have a System.Web.UI.UserControl as custom control and I have a javascript block for user control. The problem is I want to bring src attribute... -
ascx... in a class.vb
I made a class in an other file than the aspx one. This class is juste an HtmlTable, it looks like a window, and i'd like to add a property to this... -
[ASCX] Add an ascx in a webcontrol...
hey there, ok i made a class, that inherits webcontrol, and i add an htmltable to it. I was wondering how to declare an ascx file as an object in... -
Placehoder and ASCX
you could pass to your placeholder1 a reference to placeholder2... so from inside placeholder1's ascx u could write something like this: ... -
alien2_51 #2
Re: ascx... again :'(
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" <Quentin.Casasnovas@wanadoo.Fr> wrote in message
news:e3xAoI6VDHA.1204@TK2MSFTNGP12.phx.gbl...chose> 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 imy> 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 intotry> page and for now there isn't any problem... The problem shows up when ii> to change the AscxFile property as to add a usercontrol into my control...project> put in the porperty the file path of an ascx file that is in the webnow> 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 daysthank> 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> to all people who's gonna help me :)
>
> Scuse my bad english :-S
>
>
alien2_51 Guest
-
Quentin #3
Re: ascx... again :'(
I've just tried your code and it doesn't work... thank you for your response
:)
"alien2_51" <dan.billow@n.o.s.p.a.m.monacocoach.com> a écrit dans le message
de news: #8BHLg7VDHA.2104@TK2MSFTNGP10.phx.gbl...instance> It looks as if InnerPage never gets initialized, maybe create a newweb> 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" <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 ai> > 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 wherecontrol...> chose> > 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> my> > 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> try> > page and for now there isn't any problem... The problem shows up when i> > to change the AscxFile property as to add a usercontrol into mygot> i> project> > put in the porperty the file path of an ascx file that is in the web> > directory, for example "test.ascx" and after validating my property ian> > this error : "the object reference is not defined at the "instance" of> now> > 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> thank> > 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>> > to all people who's gonna help me :)
> >
> > Scuse my bad english :-S
> >
> >
>
Quentin Guest



Reply With Quote

