locked
ServerControl Inner property RRS feed

  • Question

  • User2097818059 posted

    I am writing a server control that is to replace the ASP.NET SQLDataSource. I want it to have an innerproperty that can be set to diffent inherited types. Is this possible or do I need to pass the ID of the dependent control and declare it outside of my control? Here is what I want it to act like:

    <sb:SBObjectDataSource runat="Server" ID="SBObjectDataSource1" ConnectionString="..."
            SelectCommand="SELECT * FROM Contacts;">
            <CacheManager>
                <sb:SBCacheManager runat="server"/>
            </CacheManager>
     </sb:SBObjectDataSource>

    My goal is to create diffrent cache managers and have them inherit from one type so that I can have different kinds of caching like Session etc....

    Hear is the property:

            [Browsable(false)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            [PersistenceMode(PersistenceMode.InnerProperty)]
            public SBCacheManager CacheManager
            {
                get;
                set;
            }

    This does not work:

    Friday, March 16, 2012 2:14 PM

All replies

  • User3866881 posted

    want it to have an innerproperty that can be set to diffent inherited types.

    What do you mean by that?if a property can be set to different kinds of inherited types……which "inherited types" do you want?And you should find a common father class for them……

    Saturday, March 17, 2012 9:33 PM
  • User2097818059 posted
    Yeah. I know how to create a base class. My question is how do I support this in markup.
    Saturday, March 17, 2012 9:58 PM
  • User3866881 posted

    Please change to this:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    Sunday, March 18, 2012 1:32 AM
  • User2097818059 posted

    That helped but now I can set properties on it but it doesnt allow me to decalre diffrent instances.

    I can do the following:

        <sb:SBObjectDataSource runat="Server" ID="ods" ConnectionString="Data Source=HOU-SQLDEV03;Integrated Security=True"
            SelectCommand="SELECT * FROM Contacts; SELECT * FROM Issues;">
            <CacheManager />
        </sb:SBObjectDataSource>

    But I want to be able to do the above and set the property to an instance of an object that is inherited from a base class.

    Monday, March 19, 2012 10:24 AM
  • User3866881 posted

    But I want to be able to do the above and set the property to an instance of an object that is inherited from a base class.

    Well……You've been back to what I said above……Make sure that all of your classes MUST inherit from a base one。

    And I cannot understand what you really want?Show us your expected codes :)

    Monday, March 19, 2012 9:26 PM
  • User2097818059 posted
    <sb:SBObjectDataSource runat="Server" ID="SBObjectDataSource1" ConnectionString="..."
           
    SelectCommand="SELECT * FROM Contacts;">
           
    <CacheManager>
               
    <sb:SBCacheManager runat="server"/>
           
    </CacheManager>
     
    </sb:SBObjectDataSource>

    I want it to behave like inner control collections but I dont need a collection I just need a single item for the property. The above code is what I am going for but it does not work.

    The reason I am doing it is I want to be able to plug in diffrent SBCacheManager objects that may behave diffrently.

    I get the folloing error:

    SBCacheManager' does not have a public property named 'SBCacheManager'.

    I assume this means it is looking for a property of CacheManager. I am trying to assign it an instance. Just like I would do this in code behind:

    ods.CacheManager = new SBCacheManager();
    Wednesday, March 21, 2012 11:16 AM