Loading a User Control With Propertys

Discussion in 'ASP .Net Building Controls' started by kjok, Sep 28, 2005.

  1. kjok

    kjok Guest

    I have a usercontrol with som propertys. I want to make a public
    function that loads this control, add the values to the propertys and
    put the control in a placeholder. The code remains in the App_Code
    Directory.

    My problem is that the control(as far as i know) doesnt load. Here is
    the Code

    Dim toc As New UserControl
    toc.AppRelativeTemplateSourceDirectory =
    "~/application/controls/alfaSearch"
    toc.AppRelativeVirtualPath =
    "~/application/controls/alfaSearch/alfasearch.ascx"

    toc.LoadControl("~/application/controls/alfaSearch/alfasearch.ascx")
    Dim CurrentType As Type = toc.GetType()
    Dim cAttrib As System.Reflection.PropertyInfo =
    CurrentType.GetProperty("HiddenField")
    Dim cAttrib1 As System.Reflection.PropertyInfo =
    CurrentType.GetProperty("CurrentActive")
    cAttrib.SetValue(toc, FieldName,
    Reflection.BindingFlags.SetProperty, Nothing, Nothing, Nothing)
    cAttrib1.SetValue(toc, TmpHiddenAlfa,
    Reflection.BindingFlags.SetProperty, Nothing, Nothing, Nothing)
    TmpPlaceHolder.Controls.Add(toc)

    When i get to "cAttrib.SetValue(toc, FieldName,
    Reflection.BindingFlags.SetProperty, Nothing, Nothing, Nothing)"
    i get an error "Object Reference not set to an instance of an object"
    And toc.controls.count return 0
     
    kjok, Sep 28, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3JpZGhhcg==?=
    Replies:
    1
    Views:
    461
    =?Utf-8?B?RWx0b24gVw==?=
    Nov 18, 2005
  2. VanReenenc
    Replies:
    1
    Views:
    485
    VanReenenc
    Jul 2, 2006
  3. cipher

    Setter Propertys' mro?

    cipher, Sep 7, 2008, in forum: Python
    Replies:
    3
    Views:
    280
    cipher
    Sep 7, 2008
  4. Herman Geovany Ayala Zúñiga

    Multiple Array Strings propertys

    Herman Geovany Ayala Zúñiga, Jul 12, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    108
    Herman Geovany Ayala Zúñiga
    Jul 12, 2006
  5. Andreas Schulze

    modify HttpMethod or HttpRequest propertys

    Andreas Schulze, Oct 28, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    205
    Dan Rogers
    Nov 18, 2004
Loading...

Share This Page