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:
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……
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();
Visit my blog at:
http://startingdotneprogramming.blogspot.com
KenParkerJr
Participant
1081 Points
270 Posts
ServerControl Inner property
Mar 16, 2012 06:14 PM|LINK
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:
http://startingdotneprogramming.blogspot.com
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ServerControl Inner property
Mar 18, 2012 01:33 AM|LINK
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……
KenParkerJr
Participant
1081 Points
270 Posts
Re: ServerControl Inner property
Mar 18, 2012 01:58 AM|LINK
http://startingdotneprogramming.blogspot.com
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ServerControl Inner property
Mar 18, 2012 05:32 AM|LINK
Please change to this:
KenParkerJr
Participant
1081 Points
270 Posts
Re: ServerControl Inner property
Mar 19, 2012 02:24 PM|LINK
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.
http://startingdotneprogramming.blogspot.com
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ServerControl Inner property
Mar 20, 2012 01:26 AM|LINK
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 :)
KenParkerJr
Participant
1081 Points
270 Posts
Re: ServerControl Inner property
Mar 21, 2012 03:16 PM|LINK
<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:
http://startingdotneprogramming.blogspot.com