473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help Me! WebCustomControl

Hi,
Im building a WebCustomControl. In my principal class (Inherits from
WebControl), have a property of type MyCollection (Inherits from
CollectionBase), which is a MyItem collection. To mantain the properties of
each MyItem in MyCollection I need set a special ID to each property of
MyItem, and for this, I need access to my principal class, but... each item
of MyCollection is created at desing time... i can't pass an object as
argument in the constructor. I can catch the creation of each MyItem at
design time creating MyCollectionEditor( Inherits from CollectionEditor),
overriding CreateInstance method, i can pass anything to MyItem Constructor,
but can't access to the principal class from MyCollectionEditor, because i
don't know wich object instance MyCollectionEditor (Attirubute).
The question... How to identify the ViewState of each MyItem property if i
can't access to the principal class to set an UniqueID? :(

Thanks!
Nov 19 '05 #1
5 1265
I am assuming your question is how to save each MyItem type from
MyCollection into view state for your principal control so it may be created
on postback.

You should implement IStateManager on MyCollection. In the save/load
ViewState methods of your principal control, you should call the
IStateManager.methods of MyCollection. MyCollection would then go through
and save its viewstate in what ever manner you need to.

You do not need to get the ID of the principal control to work ViewState
properly. The ViewState for MyCollection is placed inside the ViewState
container for a specific Control.

If this doesn't answer your question, or have another one, continue this
thread.

HTH,

bill

"Arnold" <no@spam.com> wrote in message
news:Ol*************@TK2MSFTNGP10.phx.gbl...
Hi,
Im building a WebCustomControl. In my principal class (Inherits from
WebControl), have a property of type MyCollection (Inherits from
CollectionBase), which is a MyItem collection. To mantain the properties of each MyItem in MyCollection I need set a special ID to each property of
MyItem, and for this, I need access to my principal class, but... each item of MyCollection is created at desing time... i can't pass an object as
argument in the constructor. I can catch the creation of each MyItem at
design time creating MyCollectionEditor( Inherits from CollectionEditor),
overriding CreateInstance method, i can pass anything to MyItem Constructor, but can't access to the principal class from MyCollectionEditor, because i
don't know wich object instance MyCollectionEditor (Attirubute).
The question... How to identify the ViewState of each MyItem property if i
can't access to the principal class to set an UniqueID? :(

Thanks!

Nov 19 '05 #2
I override the LoadViewState and SaveViewState of my principal Control and
never raised the LoadViewState Method, and implement IStateManager in
MyCollection, but I don't know wich instructions set in these methods.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am assuming your question is how to save each MyItem type from
MyCollection into view state for your principal control so it may be created on postback.

You should implement IStateManager on MyCollection. In the save/load
ViewState methods of your principal control, you should call the
IStateManager.methods of MyCollection. MyCollection would then go through
and save its viewstate in what ever manner you need to.

You do not need to get the ID of the principal control to work ViewState
properly. The ViewState for MyCollection is placed inside the ViewState
container for a specific Control.

If this doesn't answer your question, or have another one, continue this
thread.

HTH,

bill

"Arnold" <no@spam.com> wrote in message
news:Ol*************@TK2MSFTNGP10.phx.gbl...
Hi,
Im building a WebCustomControl. In my principal class (Inherits from
WebControl), have a property of type MyCollection (Inherits from
CollectionBase), which is a MyItem collection. To mantain the properties

of
each MyItem in MyCollection I need set a special ID to each property of
MyItem, and for this, I need access to my principal class, but... each

item
of MyCollection is created at desing time... i can't pass an object as
argument in the constructor. I can catch the creation of each MyItem at
design time creating MyCollectionEditor( Inherits from CollectionEditor), overriding CreateInstance method, i can pass anything to MyItem

Constructor,
but can't access to the principal class from MyCollectionEditor, because i don't know wich object instance MyCollectionEditor (Attirubute).
The question... How to identify the ViewState of each MyItem property if i can't access to the principal class to set an UniqueID? :(

Thanks!


Nov 19 '05 #3
Here is the flow you will probably want to do.

public class myControl : WebControl
{
protected override void LoadViewState(object savedState)
{
Pair p = savedState as Pair;
if ( p != null )
{
base.LoadViewState( p.First );
Collection.LoadViewState( p.Second );
}
}

protected override object SaveViewState()
{
object state1 = base.SaveViewState();
object state2 = Collection.SaveViewState();

return new Pair( state1, state2 );
}

public myCollection Collection;
}

public class myCollection : CollectionBase, IStateManager
{
public object SaveViewState()
{
//save the state of the collection and return an object.
}

public void LoadViewState(object state)
{
//load the state from the object passed. It will be the same as was
returned by SaveViewState.
}
}

Here is some additional reference.
http://msdn.microsoft.com/library/de...StateTopic.asp
http://msdn.microsoft.com/library/de...StateTopic.asp

This is a more advanced topic and I wish you the best of luck. If you need
any more pointers let me know.

Good luck!

bil
"Arnold" <no@spam.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
I override the LoadViewState and SaveViewState of my principal Control and
never raised the LoadViewState Method, and implement IStateManager in
MyCollection, but I don't know wich instructions set in these methods.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am assuming your question is how to save each MyItem type from
MyCollection into view state for your principal control so it may be created
on postback.

You should implement IStateManager on MyCollection. In the save/load
ViewState methods of your principal control, you should call the
IStateManager.methods of MyCollection. MyCollection would then go through
and save its viewstate in what ever manner you need to.

You do not need to get the ID of the principal control to work ViewState
properly. The ViewState for MyCollection is placed inside the ViewState
container for a specific Control.

If this doesn't answer your question, or have another one, continue this
thread.

HTH,

bill

"Arnold" <no@spam.com> wrote in message
news:Ol*************@TK2MSFTNGP10.phx.gbl...
Hi,
Im building a WebCustomControl. In my principal class (Inherits from
WebControl), have a property of type MyCollection (Inherits from
CollectionBase), which is a MyItem collection. To mantain the properties
of
each MyItem in MyCollection I need set a special ID to each property

of MyItem, and for this, I need access to my principal class, but... each

item
of MyCollection is created at desing time... i can't pass an object as
argument in the constructor. I can catch the creation of each MyItem at design time creating MyCollectionEditor( Inherits from

CollectionEditor), overriding CreateInstance method, i can pass anything to MyItem

Constructor,
but can't access to the principal class from MyCollectionEditor,
because i don't know wich object instance MyCollectionEditor (Attirubute).
The question... How to identify the ViewState of each MyItem property
if
i can't access to the principal class to set an UniqueID? :(

Thanks!



Nov 19 '05 #4
Thanks! Really Thank you for help me.

Now the LoadViewState is raised, but when i save the collection lunch an
error about can't savestate of objects with TypeConverter of
ReferenceConverter, how can I save the collection of MyItems?

Thanks again.

"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:ec**************@TK2MSFTNGP09.phx.gbl...
Here is the flow you will probably want to do.

public class myControl : WebControl
{
protected override void LoadViewState(object savedState)
{
Pair p = savedState as Pair;
if ( p != null )
{
base.LoadViewState( p.First );
Collection.LoadViewState( p.Second );
}
}

protected override object SaveViewState()
{
object state1 = base.SaveViewState();
object state2 = Collection.SaveViewState();

return new Pair( state1, state2 );
}

public myCollection Collection;
}

public class myCollection : CollectionBase, IStateManager
{
public object SaveViewState()
{
//save the state of the collection and return an object.
}

public void LoadViewState(object state)
{
//load the state from the object passed. It will be the same as was
returned by SaveViewState.
}
}

Here is some additional reference.
http://msdn.microsoft.com/library/de...StateTopic.asp http://msdn.microsoft.com/library/de...StateTopic.asp
This is a more advanced topic and I wish you the best of luck. If you need any more pointers let me know.

Good luck!

bil
"Arnold" <no@spam.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
I override the LoadViewState and SaveViewState of my principal Control and
never raised the LoadViewState Method, and implement IStateManager in
MyCollection, but I don't know wich instructions set in these methods.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am assuming your question is how to save each MyItem type from
MyCollection into view state for your principal control so it may be created
on postback.

You should implement IStateManager on MyCollection. In the save/load
ViewState methods of your principal control, you should call the
IStateManager.methods of MyCollection. MyCollection would then go

through and save its viewstate in what ever manner you need to.

You do not need to get the ID of the principal control to work ViewState properly. The ViewState for MyCollection is placed inside the ViewState container for a specific Control.

If this doesn't answer your question, or have another one, continue this thread.

HTH,

bill

"Arnold" <no@spam.com> wrote in message
news:Ol*************@TK2MSFTNGP10.phx.gbl...
> Hi,
> Im building a WebCustomControl. In my principal class (Inherits from
> WebControl), have a property of type MyCollection (Inherits from
> CollectionBase), which is a MyItem collection. To mantain the properties of
> each MyItem in MyCollection I need set a special ID to each property of > MyItem, and for this, I need access to my principal class, but... each item
> of MyCollection is created at desing time... i can't pass an object as > argument in the constructor. I can catch the creation of each MyItem at > design time creating MyCollectionEditor( Inherits from

CollectionEditor),
> overriding CreateInstance method, i can pass anything to MyItem
Constructor,
> but can't access to the principal class from MyCollectionEditor,

because
i
> don't know wich object instance MyCollectionEditor (Attirubute).
> The question... How to identify the ViewState of each MyItem

property if
i
> can't access to the principal class to set an UniqueID? :(
>
> Thanks!
>
>



Nov 19 '05 #5
Ready. Just with a MyItem array.
THanks again for all!!

"Arnold" <no@spam.com> wrote in message
news:ut*************@TK2MSFTNGP10.phx.gbl...
Thanks! Really Thank you for help me.

Now the LoadViewState is raised, but when i save the collection lunch an
error about can't savestate of objects with TypeConverter of
ReferenceConverter, how can I save the collection of MyItems?

Thanks again.

"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:ec**************@TK2MSFTNGP09.phx.gbl...
Here is the flow you will probably want to do.

public class myControl : WebControl
{
protected override void LoadViewState(object savedState)
{
Pair p = savedState as Pair;
if ( p != null )
{
base.LoadViewState( p.First );
Collection.LoadViewState( p.Second );
}
}

protected override object SaveViewState()
{
object state1 = base.SaveViewState();
object state2 = Collection.SaveViewState();

return new Pair( state1, state2 );
}

public myCollection Collection;
}

public class myCollection : CollectionBase, IStateManager
{
public object SaveViewState()
{
//save the state of the collection and return an object.
}

public void LoadViewState(object state)
{
//load the state from the object passed. It will be the same as was
returned by SaveViewState.
}
}

Here is some additional reference.

http://msdn.microsoft.com/library/de...StateTopic.asp

http://msdn.microsoft.com/library/de...StateTopic.asp

This is a more advanced topic and I wish you the best of luck. If you

need
any more pointers let me know.

Good luck!

bil
"Arnold" <no@spam.com> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
I override the LoadViewState and SaveViewState of my principal Control and never raised the LoadViewState Method, and implement IStateManager in
MyCollection, but I don't know wich instructions set in these methods.
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> I am assuming your question is how to save each MyItem type from
> MyCollection into view state for your principal control so it may be
created
> on postback.
>
> You should implement IStateManager on MyCollection. In the save/load > ViewState methods of your principal control, you should call the
> IStateManager.methods of MyCollection. MyCollection would then go

through
> and save its viewstate in what ever manner you need to.
>
> You do not need to get the ID of the principal control to work ViewState > properly. The ViewState for MyCollection is placed inside the ViewState > container for a specific Control.
>
> If this doesn't answer your question, or have another one, continue this > thread.
>
> HTH,
>
> bill
>
> "Arnold" <no@spam.com> wrote in message
> news:Ol*************@TK2MSFTNGP10.phx.gbl...
> > Hi,
> > Im building a WebCustomControl. In my principal class (Inherits from > > WebControl), have a property of type MyCollection (Inherits from
> > CollectionBase), which is a MyItem collection. To mantain the

properties
> of
> > each MyItem in MyCollection I need set a special ID to each
property
of
> > MyItem, and for this, I need access to my principal class, but... each > item
> > of MyCollection is created at desing time... i can't pass an
object as > > argument in the constructor. I can catch the creation of each

MyItem at
> > design time creating MyCollectionEditor( Inherits from
CollectionEditor),
> > overriding CreateInstance method, i can pass anything to MyItem
> Constructor,
> > but can't access to the principal class from MyCollectionEditor,

because
i
> > don't know wich object instance MyCollectionEditor (Attirubute).
> > The question... How to identify the ViewState of each MyItem

property
if
i
> > can't access to the principal class to set an UniqueID? :(
> >
> > Thanks!
> >
> >
>
>



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
2
by: news | last post by:
Hello All, As a VB6/C/C++ (and some Java) developer, I've been toying with c# for the last couple of weeks. I'm currently trying to create a grid of 3x3 with each cell containing numbers from 1...
0
by: Amar | last post by:
I am trying to create a WebCustomControl which inherits from System.Web.UI.Page. My purpose for this is to create a template form, that will be used from all the others pages of my project. My...
1
by: Lars Netzel | last post by:
How do I set default values to the "default" properties, like Width, height, Visible, Backcolor... in a WebCustomControl that I'm developing? Best Regards/ Lars
1
by: Cristian | last post by:
Hi, I'm building a WebCustomControl, the principal class which inherits from WebControl has the property ViewState, and I want to access to the ViewState from other classes in my project, but I...
3
by: Qwert | last post by:
Hello, if you have a WebCustomControl ( inherits from System.Web.UI.WebControls.WebControl ), how do you create an event that responses to the movement of the cursor above the control? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.