Property on Custom Control

Discussion in 'ASP .Net Web Controls' started by Keld, Sep 29, 2005.

  1. Keld

    Keld 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
    Keld, Sep 29, 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. TS
    Replies:
    5
    Views:
    397
    Steven Cheng[MSFT]
    Jul 6, 2007
  2. Matt Sokol
    Replies:
    2
    Views:
    365
    Theo Tillotson
    Aug 7, 2003
  3. Rob Joosen

    Keep custom property-value in custom rendered control

    Rob Joosen, May 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    132
    Rob Joosen
    May 12, 2004
  4. Zarko Gajic

    Custom Attributes (AttributeTargets.Property) and Property Type

    Zarko Gajic, Apr 7, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    423
    Zarko Gajic
    Apr 7, 2005
  5. anon
    Replies:
    0
    Views:
    201
Loading...

Share This Page