Skip Navigation Links / Posts / Post
Search site. 
Powered by Google
Darren Neimke (Me)

My Book

Readify

">ASP.NET MVP


Interesting Portals 

NetVibes
This portal feels similar to PageFlakes in many ways but I love their gallery. They also have a feature whre certain chrome elements only become visible when you hover over the web part.

Xtra
A New Zealand news portal. I especially liked the content rotator web part at the top of the middle row. Seems like a nice way to allow a user to browse through data.

 

Posts Archive 

MarkItUp.Web.Personalization

Categories

Just wanted to discuss a component that I've uploaded to ProjectDistributor:

    Personalization

This is one of the first web controls that I created for myself back when I started getting into ASP.NET and is designed to abstract away the complexity of working with cookies which have many keys and sub-keys.  The component itself is designed to work around the notion of a "store" - which is the abstraction of a key.  When you work with Personalization you must mention which store you are working with up front, ie:

Personalization p = new Personalization("CommentForm_ascx") ;

if( p.Items["chkRememberMe"] != null ) {
   
this.chkRememberMe.Checked = bool.Parse(p.Items["chkRememberMe"].ToString()) ;
    if( this.chkRememberMe.Checked ) {
        this.txtName.Text = p.Items["txtName"].ToString() ;
        this.txtUrl.Text = p.Items["txtUrl"].ToString() ;
    }
}

The above snippet opens a store named "CommentForm_ascx" and reads keys (which map to sub-keys) from it.  Notice how the component lends itself to logically creating stores around specific page functions.  This snippet would normally appear in your page load code to set the initial state of a page based on some persisted personalization settings.

Conversely, in your page unload (or pre render) logic, you should persist settings back into the personalization store like so:

protected override void OnPreRender(EventArgs e) {
    base.OnPreRender (e);
   
Personalization p = new Personalization("CommentForm_ascx") ;

   
if( this.chkRememberMe.Checked ) {
       
p.SetValue("chkRememberMe", "true");
       
p.SetValue("txtName", this.txtName.Text);
       
p.SetValue("txtUrl", this.txtUrl.Text);
   
}else{
       
p.Remove("chkRememberMe") ;
       
p.Remove("txtName") ;
       
p.Remove("txtUrl") ;
    }
}

posted 7/9/2005 3:12:26 AM

 

Comments:

There are no comments to display for this post.

 

Comments are currently disabled for this post.