PC Review


Reply
Thread Tools Rate Thread

Avoid properties persistence in ASP.NET

 
 
Gilberto Carcano
Guest
Posts: n/a
 
      18th Mar 2005
Is there a way to avoid public custom properties to persist in the
ASPX code?
I'have a class for columns collection in a Web Control i'm writing.
This class must to implement the IStateManager interface and so the
ITrackingManager read-only property is required. When the control
persist the collection it persist this property too and generate a
runtime error.
I've readed abouth the NotSerialized attribute but it's a solution for
public fiels only (not for properties).
Is there anyone can help me ?
 
Reply With Quote
 
 
 
 
Olorin
Guest
Posts: n/a
 
      18th Mar 2005
Puoi postare un esempio?

Con serializzazione ad Xml, ad esempio, posso scrivere

[XmlRoot(ElementName("MyClass"))]
public class MyClass
{
private string s = "Ciao";

[XmlIgnore]
public string MyProperty
{
get { return s; }
set { s = value; }
}
}

hmmmm.... mi sa che non ho capito il tuo problema, o che la
serializzazione che stai facendo tu segue regole diverse da quella per
Xml che ho usato io.

F.O.R.

 
Reply With Quote
 
Gilberto Carcano
Guest
Posts: n/a
 
      18th Mar 2005
Scusa se non ho descritto bene il mio problema:
Stò scrivendo un Web Control che richiede una proprietà di tipo derivato
da CollectionBase. Per poter gestire correttamente il ViewState questo
tipo deve implementare l'interfaccia IStateManager che richiede una
proprietà pubblica IsTrackingViewState. Se definisco questa proprietà e
non uso nessun attributo ottengo due effetti indesiderati:
1) la proprietà viene listata nel properties browser a design time
2) la proprietà viene resa persistente nel codice ASPX della pagina che
contiene il controllo.

Ho comunque risolto entrambi i problemi usando BrowsableAttribute(false)
e
DesignerSerializationVisibility(Hidden)
come attributi della proprietà da "nascondere".

Non avevo googlato abbastanza :-<
Grazie comunque.


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

Thread Tools
Rate This Thread
Rate This Thread:

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
Printer, properties, finishing - how do I avoid scaling? konyusz Microsoft Word Document Management 1 5th Aug 2008 07:19 AM
simple questions re: using WebForm to edit object properties / persistence jason Microsoft ASP .NET 0 2nd Jun 2005 06:02 PM
Re: How do use VBA to avoid reverting to my default properties for a l Bob Phillips Microsoft Excel Programming 0 29th Jun 2004 08:22 PM
Not allowing users to avoid startup properties Chris Microsoft Access Form Coding 2 21st May 2004 11:13 AM
Not allowing users to avoid startup properties Chris Microsoft Access Security 2 21st May 2004 11:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 PM.