Fabio Carucci's WebLogs

"...You may say I'm a dreamer, but I'm not the only one..." (Imagine)
posts - 51, comments - 41, trackbacks - 27

My Links

News



PER CONSULENZE SCRIVERE SU "CONTACT"

Contattami se sono online!

This is my personal blog. These postings are provided "AS IS" with no warranties, and confer no rights. The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer.








View Fabio Carucci's profile on LinkedIn

Vuoi ricevere i miei post nella tua email? Iscriviti

Add to Technorati Favorites



http://www.csthota.com/blogmap/



Locations of visitors to this page





Tag Cloud

Archives

Post Categories

1 - Pubblicazioni

2 - Conferenze

3 - Links

4 - Blogs

L'arte di lavorare con le WebPart - #5

Con l'attributo [Personalizable] dichiariamo ad ASP.NET di voler persistere nello storage di default il valore di una property da noi creata all'interno della web part. E fin qui nulla da dire.

Peccato però che la property, se non contiene un semplice valore bensì un dato più complesso (collections o riferimenti a oggetti business) e questo viene modificato durante il ciclo di vita dell'applicazione - e quindi anche della web part - l'attributo [Personalizable] non è più sufficiente per persistere tale valore.

Occorre quindi utilizzare il metodo SetPersonalizationDirty()

quindi, una cosa di questo tipo:

public class EditorWebPart : WebPart
{
    
private BaseEditor _editor;
    
    [Personalizable]
    
public BaseEditor Editor
    {
        
get return _editor; }
        
set { _editor = value; }
    }    
}

essendo Editor una property complessa, perchè ha come tipo BaseEditor, non si potrà persistere il suo stato (modificato) in questo modo:

EditorWebPart.Editor.Title = this.TitleText.Text;
EditorWebPart.Editor.Content = 
this.ContentText.Text;

poichè il meccanismo di personalization di ASP.NET non sarà in grado di accorgersi da solo che la property Editor è cambiata, quindi:

EditorWebPart.Editor.Title = this.TitleText.Text;
EditorWebPart.Editor.Content = 
this.ContentText.Text;
this.SetPersonalizationDirty();

aggiungendo, alla fine delle modifiche, il SetPersonalizationDirty() diremo ad ASP.NET di persistere lo stato nascosto della property.

 

powered by IMHO 1.3

Print | posted on mercoledì 6 dicembre 2006 23.29 | Filed Under [ ASP.NET 2.0 WebPart ]

Feedback

Gravatar

# Sex.

Sex.
18/12/2008 5.27 | Sex.
Gravatar

# Free ringtones for dash t-mobile.

Free nokia ringtones. Download free ringtones. Free ringtones. Free phone ringtones. Free ringtones canada.
Gravatar

# Zoo sex tube.

Zoo sex tube.
19/12/2008 8.54 | Zoo sex tube.
Gravatar

# Rape sex.

Male rape. Rape fantasy. Hentai rape. Rape sites.
21/12/2008 7.41 | Rape story.
Gravatar

# Sex positions.

My first sex teacher. Gay sex. Sex stories. Free sex video. Sex positions.
23/12/2008 7.33 | Sex.
Gravatar

# Shakira.

Shakira nude. Shakira biography. Naked shakira. Shakira.
24/12/2008 16.18 | Shakira lyrics.
Gravatar

# How tall is shakira.

Shakira s videos. Shakira s life. Shakira biography. Shakira sexy photos bio and more. Shakira. Shakira nude.
24/12/2008 20.51 | Shakira.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 4 and 4 and type the answer here:

Powered by: