ProfileView can now be used for user administration#
By far, the most common feature request for my ProfileView control was the ability to edit the profile of any user in the system. Until now, the control could only be used by the current user to edit their own profile. I thought it was a limitation of the Profile provider framework, until I discovered ProfileBase.Create(). I apologize to everyone that has been waiting for this much needed feature for so long.

Just set the UserName property on the control to edit a different user. The property is null by default, which loads the current user.

Example usage in a WebForm used to edit a profile:

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)

        {

            string userName = Request.QueryString["username"];

            if (!String.IsNullOrEmpty(userName))

            {

                ProfileView1.UserName = userName;

            }

        }

    }



Download the latest code from the ProfileView project page.
Saturday, June 24, 2006 11:47:41 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

New release of ProfileView#
I've posted the source and binary for the latest release of my ProfileView ASP.NET server control. I was finally able to address the much requested fix to make the order of the properties displayed at runtime reflect the order they are declared in the web.config. Here are the release notes:
  • Properties now display in the order they are listed in web.config
  • Design-time view now uses same rendering method as runtime
  • Fixed design-time bug that caused it to fail when a profile property type was not specified
  • Design-time view now has a Smart Tag to allow you to preview an anonymous user's profile
Sunday, January 08, 2006 8:46:49 PM (Central Standard Time, UTC-06:00) #    Comments [7]  | 

 

Accessing web.config at Design Time in .NET 2.0#

When creating a designer for an ASP.NET server control, it is often very useful to read settings from the user's web.config file. In previous versions of the .NET Framework, you had to jump through hoops to access the web.config file at design time. I was very thankful for this solution when I needed it, but I'm happy to move on. The dependency on EnvDTE felt wrong, and the fact that it used COM interop with the VS.NET IDE meant it probably would not work with any other tool.

Thankfully, in .NET 2.0, it is much simpler. If you want to get the full path to web.config (useful for parsing the XML manually), it has been reduced to:

using System.Web.UI.Design;
//...
IWebApplication webApp = (IWebApplication)Component.Site.GetService(
typeof(IWebApplication) );
IProjectItem item = webApp.GetProjectItemFromUrl("~/web.config");
string webConfigPath = item.PhysicalPath;

Note: you will want to check for nulls and handle appropriately. The call to GetService could return null if the design tool hosting your control does not support this service (something other than VS.NET). And of course the call to GetProjectItemFromUrl could fail if there is no web.config in the project.

Even better, instead of parsing web.config yourself, you can get strongly-typed access to the configuration using the new classes in the System.Configuration namespace. For example, in my ProfileView control, I use code similar (more null checking) to the following to discover information about the configured profile properties:

using System.Configuration;
using System.Web.Configuration;
using
System.Web.UI.Design;
//...

IWebApplication webApp = (IWebApplication)Component.Site.GetService(
typeof(IWebApplication) );
Configuration config = webApp.OpenWebConfiguration(true);
ConfigurationSectionGroup systemWeb = config.GetSectionGroup("system.web");
ProfileSection profileSection = (ProfileSection)systemWeb.Sections["profile"];

foreach (ProfilePropertySettings configProperty in profileSection.PropertySettings)
{ // read the settings in each configProperty }

Once you get the Configuration object as demonstrated above, reading a value out of the appSettings section is as easy as:

config.AppSettings.Settings["maxRetries"].Value

Monday, January 02, 2006 12:23:51 PM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

ProfileView#

ProfileView

This is the official home of my new ProfileView control. ProfileView is an ASP.NET 2.0 server control that enables your users to view and/or edit their Personalization Profile. Read my original post about it for more background.

Download

The source code is now freely available! Download it and do with it as you wish. If you add any features, I would appreciate it if let me know about it using the contact information on my blog.

Download the binary

Download the source code

How to use

Register the assembly at the top of the aspx page that will host the control:

<%@ Register Assembly="FlimFlan.WebControls" Namespace="FlimFlan.WebControls" TagPrefix="flim" %>

Place the control markup where you want the ProfileView to appear:

<flim:ProfileView ID="UserProfile" runat="server" />

History

June 24, 2006: Release 1.2.524.2006

  • Added the UserName property to allow you to edit the profile of any user in the system - not just the current user.

January 8, 2006: Release 1.1.108.2006

  • Properties now display in the order they are listed in web.config
  • Design-time view now uses same rendering method as runtime
  • Fixed design-time bug that caused it to fail when a profile property type was not specified
  • Design-time view now has a Smart Tag to allow you to preview an anonymous user's profile

October 30, 2005: Updated for the final release (RTM) version of Visual Studio 2005 / .NET Framework 2.0

July 7, 2004: A significantly updated version is now available.

  • The design-time view now shows your actual profile properties, instead of sample properties
  • New ReadOnly mode allows you to use ProfileView to display a user's profile, without allowing them to edit it.
  • Now supports profile groups

TODO:

  • Add the ability to disable display of profile properties by their “group“
  • Create a templated UI (or at least more style/formatting properties)
  • Allow better support for display of custom types/collections
Sunday, October 30, 2005 8:27:07 PM (Central Standard Time, UTC-06:00) #    Comments [32]  | 

 

Significant update to ProfileView#

As promised, with the recent release of Visual Studio 2005 Beta 1, I have created an updated version of the ProfileView control.  The most noticeable new features:

  • Much better WYSIWYG experience, as the control now renders your profile at design time. (Eternal thanks to this post on accessing web.config at design-time - I searched high and low for this information and came up empty - the newsgroups are littered with unanswered questions on this.  I guess I got lucky that someone at TechEd Europe decided to talk about it. UPDATE: I've found an even better solution for accessing web.config at design-time.)
  • A new read-only mode that allows users to view their profile without being able to edit it.
  • FREE SOURCE CODE

I've also created a new home for the ProfileView files.  Instead of creating links to different versions in each blog post, each of my blog entries will now reference this article.  I will keep the article updated with all of the latest ProfileView happenings.

Go get FlimFlan.WebControls.ProfileView and tell me what you think.

Wednesday, July 07, 2004 8:07:00 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

All content © 2012, josh
About this site
Send mail to the author(s) Contact me
Feed your aggregator (RSS 2.0)
Joshua Flanagan
I am a software developer focused on continuous improvement in the .NET community
Los Techies

On this page
Archives
Rest of the world

Acknowledgements

Powered by: newtelligence dasBlog 2.1.8209.14743

Special thanks to LosTechies.com

Site theme based on the essence design by Jelle Druyts

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.