+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Seeking Advice for Implementing Personalized "Statebag"

Seeking Advice for Implementing Personalized "Statebag"

2 posts, 0 answered
  1. BobTabor
    BobTabor avatar
    17 posts
    Registered:
    12 Dec 2007
    05 Feb 2010
    Link to this post
    Hi, I'm looking to create a basic checklist.  Each end user would be able to see what's next "to-do" from our pre-set list and checkoff each item as they work through them.  Over time, we'll need to add new "to-do" items to that list.  This is used to help the user gauge their progress along a path.

    Would someone who is familiar with customizing Sitefinity be willing to give some basic direction on how best to tackle this in Sitefinity?  I realize there's a way to add Profile information by modifying the web.config and change the templates, however (1) we're looking at dozens, if not hundreds of "to-do" items, and (2) it's not easy to add new items (unless you're a developer.)

    Thank you!
    Bob
  2. BobTabor
    BobTabor avatar
    17 posts
    Registered:
    12 Dec 2007
    05 Feb 2010
    Link to this post
    I figured it out ... it was easy, actually.  In the slim chance that someone else needs this too:

    (1) I created a user control with two public properties, both strings:  ProfilePropertyName and ProfilePropertyLabel.  Add the User Control to the web.config using the normal technique.
    (2) In the usercontrol, added a single checkbox.
    (3) In the web.config, added an entry like this:

    <profile defaultProvider="AspNetSqlProfileProvider">
      ...
      <properties>
        ...
        <
    add name="MyStateBag" type="System.Collections.Specialized.StringCollection" serializeAs="Xml" />


    Note: Because I was using a custom Membership and Role provider already, I had to modify my Providers section

    <providers>
      <clear/>
        <!--
        <add name="Sitefinity" connectionStringName="DefaultConnection" applicationName="lvs" type="Telerik.DataAccess.AspnetProviders.TelerikProfileProvider, Telerik.DataAccess"/>
        -->
        <add name="AspNetSqlProfileProvider" connectionStringName="MyConnectionString" applicationName="MyApp" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/><br>
    </providers>


    (4) On Form_Load of the User Control:


    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                proCheckbox.Text = ProfilePropertyLabel;
     
                StringCollection pro = Profile.MyStateBag;
     
                if (pro.Contains(ProfilePropertyName))
                {
                    proCheckbox.Checked = true;
                }
                else
                {
                    proCheckbox.Checked = false;
                }
     
            }
     
        }



    (5) On the Checked Changed event of the Checkbox (which is autopostback)

    protected void proCheckbox_CheckedChanged(object sender, EventArgs e)
    {
        StringCollection pro = Profile.MyStateBag;
     
        if (proCheckbox.Checked)
        {
            pro.Add(ProfilePropertyName);
        }
        else
        {
            pro.Remove(ProfilePropertyName);
        }
    }


    If I need 5 checkboxes, I'll have to add my user control five times to the page, selecting new values for the ID, the ProfilePropertyName and the ProfilePropertyLabel.  That autonomy is actually fine for our purposes, but I can see how others may prefer a more "databound list" approach.
2 posts, 0 answered