Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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 ...
    2. 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...
    3. 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...
    4. [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...
    5. 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: ...
  3. #2

    Default 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...
    > 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
    >
    >

    alien2_51 Guest

  4. #3

    Default 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...
    > 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...
    > > 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139