ascx... again :'(

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 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.A dd(MaCellule)
    MaTable.Rows.Ad d(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.LoadCon trol(AscxPath)
    Me.MaTable.Rows (0).Cells(0).Co ntrols.Add(Cont rolAscx)
    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).Co ntrols.Add(Inne rPage)

    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


  • 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.WebContr ols.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.A dd(MaCellule)

    MaTable.Rows.Ad d(MaLigne)

    Me.Controls.Add (MaTable)

    End Sub

    End Class


    "Quentin" <Quentin.Casasn ovas@wanadoo.Fr > wrote in message
    news:e3xAoI6VDH A.1204@TK2MSFTN GP12.phx.gbl...[color=blue]
    > 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.A dd(MaCellule)
    > MaTable.Rows.Ad d(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.LoadCon trol(AscxPath)
    > Me.MaTable.Rows (0).Cells(0).Co ntrols.Add(Cont rolAscx)
    > End Sub
    >
    > End Class
    > ---------------------
    >
    > After that i'm going in an *.aspx of my web project, in the tool box i[/color]
    chose[color=blue]
    > 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[/color]
    my[color=blue]
    > page and for now there isn't any problem... The problem shows up when i[/color]
    try[color=blue]
    > to change the AscxFile property as to add a usercontrol into my control...[/color]
    i[color=blue]
    > put in the porperty the file path of an ascx file that is in the web[/color]
    project[color=blue]
    > 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).Co ntrols.Add(Inne rPage)
    >
    > 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[/color]
    now[color=blue]
    > 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[/color]
    thank[color=blue]
    > to all people who's gonna help me :)
    >
    > Scuse my bad english :-S
    >
    >[/color]


    Comment

    • 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.monaco coach.com> a écrit dans le message
      de news: #8BHLg7VDHA.210 4@TK2MSFTNGP10. phx.gbl...[color=blue]
      > It looks as if InnerPage never gets initialized, maybe create a new[/color]
      instance[color=blue]
      > in the New constructor...
      > Public Class SomeControl
      >
      > Inherits Web.UI.WebContr ols.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.A dd(MaCellule)
      >
      > MaTable.Rows.Ad d(MaLigne)
      >
      > Me.Controls.Add (MaTable)
      >
      > End Sub
      >
      > End Class
      >
      >
      > "Quentin" <Quentin.Casasn ovas@wanadoo.Fr > wrote in message
      > news:e3xAoI6VDH A.1204@TK2MSFTN GP12.phx.gbl...[color=green]
      > > Hello,
      > >
      > > I got a Solution, containing two projects, a project of classes, and a[/color][/color]
      web[color=blue][color=green]
      > > 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[/color][/color]
      i[color=blue][color=green]
      > > 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.A dd(MaCellule)
      > > MaTable.Rows.Ad d(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.LoadCon trol(AscxPath)
      > > Me.MaTable.Rows (0).Cells(0).Co ntrols.Add(Cont rolAscx)
      > > End Sub
      > >
      > > End Class
      > > ---------------------
      > >
      > > After that i'm going in an *.aspx of my web project, in the tool box i[/color]
      > chose[color=green]
      > > 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[/color]
      > my[color=green]
      > > page and for now there isn't any problem... The problem shows up when i[/color]
      > try[color=green]
      > > to change the AscxFile property as to add a usercontrol into my[/color][/color]
      control...[color=blue]
      > i[color=green]
      > > put in the porperty the file path of an ascx file that is in the web[/color]
      > project[color=green]
      > > directory, for example "test.ascx" and after validating my property i[/color][/color]
      got[color=blue][color=green]
      > > this error : "the object reference is not defined at the "instance" of[/color][/color]
      an[color=blue][color=green]
      > > object" on the line ----->
      > > Me.maTable.Rows (0).Cells(0).Co ntrols.Add(Inne rPage)
      > >
      > > 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[/color]
      > now[color=green]
      > > 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[/color]
      > thank[color=green]
      > > to all people who's gonna help me :)
      > >
      > > Scuse my bad english :-S
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...