Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Monday, March 26, 2012

Sequence of Validator Error Messages

Hi Team,

How I can specify the sequence of validator messages ? I tryed setting
"tabindex" property. but of no use.

Thanks in advance

CheeeeeeeeeeersHi,

You can change the order of the <asp:VALIDATOR> webcontrols in your HTML
file
to the order in which you want the messages displayed.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thanks Natty Gur... That really works. But I wonder why MS provided
"TABINDEX" !!!!!!

Cheeeeeeeeeeeeeers

"Natty Gur" <natty@.dao2com.com> wrote in message
news:#MJss5X5DHA.1632@.TK2MSFTNGP12.phx.gbl...
> Hi,
> You can change the order of the <asp:VALIDATOR> webcontrols in your HTML
> file
> to the order in which you want the messages displayed.
> Natty Gur[MVP]
> blog : http://weblogs.asp.net/ngur
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
It's there due to inheritence from WebControl.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

serialization - include collection property

Why the collection property is not included in the ouput
serialization ?

I have a custom generic collection (implements icollection): Events of
objects: Event.

Event is a simple class exposing, let's say, one property: name

Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class

Events Implements ICollection
Public EventColor as string
......

Everything works except when I save the xml file I'm expecting to get
smth like:

<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>

EVENTCOLOR attribute is not in the xml, any idea ?

Thanks,
xkeIn your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"xke" <xkeops@.gmail.comwrote in message
news:1193083502.735588.136230@.e34g2000pro.googlegr oups.com...

Quote:

Originally Posted by

Why the collection property is not included in the ouput
serialization ?
>
I have a custom generic collection (implements icollection): Events of
objects: Event.
>
Event is a simple class exposing, let's say, one property: name
>
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
>
>
Events Implements ICollection
Public EventColor as string
......
>
Everything works except when I save the xml file I'm expecting to get
smth like:
>
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
>
EVENTCOLOR attribute is not in the xml, any idea ?
>
Thanks,
xke
>


Hi Andrew,

Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.

It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.

Thanks,
xke

On Oct 22, 10:06 pm, "Andrew Faust" <and...@.andrewfaust.comwrote:

Quote:

Originally Posted by

In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?
>
--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com
>
"xke" <xke...@.gmail.comwrote in message
>
news:1193083502.735588.136230@.e34g2000pro.googlegr oups.com...
>
>
>

Quote:

Originally Posted by

Why the collection property is not included in the ouput
serialization ?


>

Quote:

Originally Posted by

I have a custom generic collection (implements icollection): Events of
objects: Event.


>

Quote:

Originally Posted by

Event is a simple class exposing, let's say, one property: name


>

Quote:

Originally Posted by

Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class


>

Quote:

Originally Posted by

Events Implements ICollection
Public EventColor as string
......


>

Quote:

Originally Posted by

Everything works except when I save the xml file I'm expecting to get
smth like:


>

Quote:

Originally Posted by

<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>


>

Quote:

Originally Posted by

EVENTCOLOR attribute is not in the xml, any idea ?


>

Quote:

Originally Posted by

Thanks,
xke- Hide quoted text -


>
- Show quoted text -


Sorry. Misread your original post.

According to this article the Serializer only supports writing out the
actual objects contained in an ICollection and not the actual properties of
the collection itself.

http://www.diranieh.com/NETSerializ...rialization.htm
I would recommend a slight restructuring to something like this

class Events
{
public string EventColor;
private List<Eventm_Events;
public Event[] UpcomingEvents
{
get { return m_Events.ToArray(); }
set {
m_Events = new List<Event>();
m_Events.AddRange(value);
}
}
}

Then serialize the Events class.

"xke" wrote:

Quote:

Originally Posted by

Hi Andrew,
>
Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.
>
It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.
>
Thanks,
xke
>
On Oct 22, 10:06 pm, "Andrew Faust" <and...@.andrewfaust.comwrote:

Quote:

Originally Posted by

In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?

--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com

"xke" <xke...@.gmail.comwrote in message

news:1193083502.735588.136230@.e34g2000pro.googlegr oups.com...

Quote:

Originally Posted by

Why the collection property is not included in the ouput
serialization ?


Quote:

Originally Posted by

I have a custom generic collection (implements icollection): Events of
objects: Event.


Quote:

Originally Posted by

Event is a simple class exposing, let's say, one property: name


Quote:

Originally Posted by

Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class


Quote:

Originally Posted by

Events Implements ICollection
Public EventColor as string
......


Quote:

Originally Posted by

Everything works except when I save the xml file I'm expecting to get
smth like:


Quote:

Originally Posted by

<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>


Quote:

Originally Posted by

EVENTCOLOR attribute is not in the xml, any idea ?


Quote:

Originally Posted by

Thanks,
xke- Hide quoted text -


- Show quoted text -


>
>
>


beautiful idea / will give it a try tomorrow

thanks,
xke

On Oct 23, 1:28 pm, Andrew Faust <afa...@.nospam.nospamwrote:

Quote:

Originally Posted by

Sorry. Misread your original post.
>
According to this article the Serializer only supports writing out the
actual objects contained in an ICollection and not the actual properties of
the collection itself.
>
http://www.diranieh.com/NETSerializ...rialization.htm
>
I would recommend a slight restructuring to something like this
>
class Events
{
public string EventColor;
private List<Eventm_Events;
public Event[] UpcomingEvents
{
get { return m_Events.ToArray(); }
set {
m_Events = new List<Event>();
m_Events.AddRange(value);
}
}
>
}
>
Then serialize the Events class.
>
>
>
"xke" wrote:

Quote:

Originally Posted by

Hi Andrew,


>

Quote:

Originally Posted by

Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.


>

Quote:

Originally Posted by

It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.


>

Quote:

Originally Posted by

Thanks,
xke


>

Quote:

Originally Posted by

On Oct 22, 10:06 pm, "Andrew Faust" <and...@.andrewfaust.comwrote:

Quote:

Originally Posted by

In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com


>

Quote:

Originally Posted by

Quote:

Originally Posted by

"xke" <xke...@.gmail.comwrote in message


>

Quote:

Originally Posted by

Quote:

Originally Posted by

>news:1193083502.735588.136230@.e34g2000pro.googlegr oups.com...


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Why the collection property is not included in the ouput
serialization ?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

I have a custom generic collection (implements icollection): Events of
objects: Event.


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Event is a simple class exposing, let's say, one property: name


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Events Implements ICollection
Public EventColor as string
......


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Everything works except when I save the xml file I'm expecting to get
smth like:


>

Quote:

Originally Posted by

Quote:

Originally Posted by

<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>


>

Quote:

Originally Posted by

Quote:

Originally Posted by

EVENTCOLOR attribute is not in the xml, any idea ?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Thanks,
xke- Hide quoted text -


>

Quote:

Originally Posted by

Quote:

Originally Posted by

- Show quoted text -- Hide quoted text -


>
- Show quoted text -

Saturday, March 24, 2012

serialize class to the viewstate

I am trying to serialize a class called Order to the ViewState. Order has
one property called LineItems, which is an ArrayList. The ArrayList holds
instances of a class named LineItem. Bother Order and LineItem are marked
with the <Serializable> attribute.

When I attempt to serialize the class using this code:

Dim xs As XmlSerializer = New XmlSerializer(GetType(Order))

Dim sw As New StringWriter()

xs.Serialize(sw, _Order)

ViewState("LineItems") = sw.ToString()

On the line xs.Serialize(sw, _Order), I get an error that reads:

The type LineItem was not expected. Use the XmlInclude or SoapInclude
attribute to specify types that are not known statically.

What am I missing?

Thanks,

Craig BuchananYou may have to specify what the array list holds with the XmlElement
attribute.

I have a list that holds two different types and I had to do apply the
following to the array list:
<XmlElement(Type:=GetType(StringCriteriaField)),
XmlElement(Type:=GetType(IntegerCriteriaField))
"Craig Buchanan" <someone@.somewhere.com> wrote in message
news:#X3bk8R5DHA.504@.TK2MSFTNGP11.phx.gbl...
> I am trying to serialize a class called Order to the ViewState. Order has
> one property called LineItems, which is an ArrayList. The ArrayList holds
> instances of a class named LineItem. Bother Order and LineItem are marked
> with the <Serializable> attribute.
> When I attempt to serialize the class using this code:
> Dim xs As XmlSerializer = New XmlSerializer(GetType(Order))
> Dim sw As New StringWriter()
> xs.Serialize(sw, _Order)
> ViewState("LineItems") = sw.ToString()
> On the line xs.Serialize(sw, _Order), I get an error that reads:
> The type LineItem was not expected. Use the XmlInclude or SoapInclude
> attribute to specify types that are not known statically.
> What am I missing?
> Thanks,
> Craig Buchanan