Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > serialization problem - eventhandling by control

Reply
Thread Tools

serialization problem - eventhandling by control

 
 
Ralf Müller
Guest
Posts: n/a
 
      12-14-2004
Hi folks!

I am developing a custom TreeView and I have got a problem with the
serialization of my TreeViewModel:

[Serializable]
public class NavigationTreeModel : ITreeModel {

public event EventHandler DataChanged;

private Folder _rootFolder;
private IList _rootElements;

public NavigationTreeModel() : this(null) {
}

public NavigationTreeModel(Folder root) {
_rootElements = new ArrayList();
RootFolder = root;
}

public Folder RootFolder {
get { return _rootFolder; }
set {
if (_rootFolder == value)
return;
if (_rootFolder != null)
_rootElements.Remove(_rootFolder);
_rootFolder = value;
if (_rootFolder != null) {
_rootElements.Add(_rootFolder);
}
OnDataChanged(EventArgs.Empty);
}
}

#region ITreeModel Member

public IList RootElements {
get {
if (_rootElements == null) {
_rootElements = new ArrayList();
if(RootFolder != null)
_rootElements.Add(RootFolder);
}
return _rootElements;
}
}

public IList GetChildren(object parent) {
if (parent is Folder) {
return ((Folder)parent).Folders;
}
return new ArrayList();
}

#endregion

protected virtual void OnDataChanged(EventArgs e) {
if (DataChanged != null)
DataChanged(this, e);
}
}

The model serializes perfectly until I set my TreeViewControl to handle its
DataChangedEvent. Then I get the following exception:
"Der Typ 'julitec.DM.Web.NavigationTreeModel' muss als 'Serializable'
markiert sein oder einen anderen TypeConverter als ReferenceConverter
haben." (= The type 'julitec.DM.Web.NavigationTreeModel' must be marked as
Serializable or have a TypeConverter other than ReferenceConverter)
I guess that is because my TreeViewControl is not serializable.
What I am asking myself (and you) now is the following: Should I really make
a Control serializable? I don't think it is a good pratice to do so since
none of the built in ASP.NET WebControls seems to be serializable. What else
could I do to overcome this problem?

Thanx in advance!



Greetings, Ralf



 
Reply With Quote
 
 
 
 
Ralf Müller
Guest
Posts: n/a
 
      12-16-2004
hi leon!

my problem is that i want to notify my control of changes that occur to the
model - not the other way round
but i have got no idea how to send an event or any kind of notifcation to my
control if i can't let it handle my model events because it is not
serializable...

could you give me an example of what you where proposing?


ralf


"Leon Friesema" <leon@@frostbits.nl> schrieb im Newsbeitrag
news:...
> On Tue, 14 Dec 2004 09:46:28 +0100, "Ralf Müller" <>
> wrote:
>
> >Hi folks!
> >
> >I am developing a custom TreeView and I have got a problem with the
> >serialization of my TreeViewModel:
> >

> [SNIP CODE]
> >
> >The model serializes perfectly until I set my TreeViewControl to handle

its
> >DataChangedEvent. Then I get the following exception:
> >"Der Typ 'julitec.DM.Web.NavigationTreeModel' muss als 'Serializable'
> >markiert sein oder einen anderen TypeConverter als ReferenceConverter
> >haben." (= The type 'julitec.DM.Web.NavigationTreeModel' must be marked

as
> >Serializable or have a TypeConverter other than ReferenceConverter)
> >I guess that is because my TreeViewControl is not serializable.
> >What I am asking myself (and you) now is the following: Should I really

make
> >a Control serializable? I don't think it is a good pratice to do so since
> >none of the built in ASP.NET WebControls seems to be serializable. What

else
> >could I do to overcome this problem?
> >
> >Thanx in advance!
> >
> >
> >
> >Greetings, Ralf
> >

>
> That indeed is the problem, the control isn't serializable and no, you
> don't want it to be.
> What you want to do, if you want to serialize the data is handle the
> control and data seperately. When a change has occured in the Control,
> you post it back to your data and serialize that.
> One minor problem though, when de-serializing you need to rewrite your
> code because it needs to repopulate the control.
>
> Leon.



 
Reply With Quote
 
 
 
 
Ralf Müller
Guest
Posts: n/a
 
      12-24-2004
First of all - Merry Xmas!

My Problem is that I've got one TreeModel and several TreeViews attached to
it. In the meanwhile I "solved" the problem storing my Model in the
Session-Collection so it does not have to be serialized on postback. But
still it would be interesting how to implement the MVC-Pattern correctly in
ASP.NET. But I guess I'd better put that in a new Post...

Greetings, Ralf


"Leon Friesema" <leon@@frostbits.nl> schrieb im Newsbeitrag
news:...
> On Thu, 16 Dec 2004 12:39:36 +0100, "Ralf Müller" <>
> wrote:
>
> >
> >
> >"Leon Friesema" <leon@@frostbits.nl> schrieb im Newsbeitrag
> >news:.. .
> >> On Tue, 14 Dec 2004 09:46:28 +0100, "Ralf Müller" <>
> >> wrote:
> >>
> >> >Hi folks!
> >> >
> >> >I am developing a custom TreeView and I have got a problem with the
> >> >serialization of my TreeViewModel:
> >> >
> >> [SNIP CODE]
> >> >
> >> >The model serializes perfectly until I set my TreeViewControl to

handle
> >its
> >> >DataChangedEvent. Then I get the following exception:
> >> >"Der Typ 'julitec.DM.Web.NavigationTreeModel' muss als 'Serializable'
> >> >markiert sein oder einen anderen TypeConverter als ReferenceConverter
> >> >haben." (= The type 'julitec.DM.Web.NavigationTreeModel' must be

marked
> >as
> >> >Serializable or have a TypeConverter other than ReferenceConverter)
> >> >I guess that is because my TreeViewControl is not serializable.
> >> >What I am asking myself (and you) now is the following: Should I

really
> >make
> >> >a Control serializable? I don't think it is a good pratice to do so

since
> >> >none of the built in ASP.NET WebControls seems to be serializable.

What
> >else
> >> >could I do to overcome this problem?
> >> >
> >> >Thanx in advance!
> >> >
> >> >
> >> >
> >> >Greetings, Ralf
> >> >
> >>
> >> That indeed is the problem, the control isn't serializable and no, you
> >> don't want it to be.
> >> What you want to do, if you want to serialize the data is handle the
> >> control and data seperately. When a change has occured in the Control,
> >> you post it back to your data and serialize that.
> >> One minor problem though, when de-serializing you need to rewrite your
> >> code because it needs to repopulate the control.
> >>
> >> Leon.

> >

>
> >hi leon!
> >
> >my problem is that i want to notify my control of changes that occur to

the
> >model - not the other way round
> >but i have got no idea how to send an event or any kind of notifcation to

my
> >control if i can't let it handle my model events because it is not
> >serializable...
> >
> >could you give me an example of what you where proposing?
> >
> >
> >ralf

>
> Ralf,
>
> what do you mean by notify my control?
> If you mean you added a Node to the TreeView == change to the Model.
> In that case, why don't you override the methods of the node-changes
> (add, remove, etc) and handle these events also within your
> (serializable) model.
>
> Leon.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EventHandling problem : Java has solution but what about Microsoft??? Herfried K. Wagner [MVP] ASP .Net 12 12-01-2005 09:40 PM
Eventhandling with TableSorter and TableFilterer cm Java 2 08-09-2004 09:36 AM
Eventhandling in Page hierarchies, how does it really work ? Claes Rådström ASP .Net 3 02-05-2004 08:47 AM
Create controls dynamic in eventhandling Andrea ASP .Net 0 12-18-2003 03:11 PM
Problem with Eventhandling in user control Franz Fitz ASP .Net Building Controls 1 10-30-2003 10:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57