Talking about new features, useful things, frustrations in .NET and so on...
14-08-2007
ASP..NET Web Parts
Web Parts are very useful to enable end users to modify the look and feel of your website : the content, appearance and even the behaviour can be changed, this is possible without writing any code.
First drag a WebPartManager control to the web page. This control must appear before any other Web Part control, otherwise a runtime exception will be thrown (and that's not exactly what we want...) Next add WebPartZone controls to the places where you want [an end user] to see Web Parts; you can do this inside a table to get a basic layout. The title can be changed in the HeaderText property. You can now start adding (in the design view) some web user controls to the WebPartZone controls by dragging and dropping.
A quick preview in a browser shows us the controls have a title "Untitled", this can easily be changed by adding title="" in the source code (the intellisense won't recognize it, don't worry about that) :
Now, all the above is quite useful, but to let the user interact with our web parts, a few things are still missing. Add an EditorZone and a CatalogZone the same way as the WebPartZone's above. Make sure not to add them to an existing WebPartZone as this will generate a runtime exception. In the EditorZone you can add an AppearanceEditorPart, LayoutEditorPart and BehaviorEditorPart, depending on what you want the end user to do. In the CatalogZone you can add a DeclarativeCatalogPart (when you want to add another instance of a predefined user control), a PageCatalogPart (to retain an existing control when you closed it) and an ImportCatalogPart (to import a non-defined user control).
When taking a quick look in the browser (after building...), you see none of the above appears... This is because the current view is set to the default view : Browse. Now let's add a control displaying the different modes, the first code that has to be written (except HTML...) ! (I chose a radiobuttonlist called rbListModes)
Make sure to set the AutoPostBack property of the control to "true" and start the application. When switching between the different display modes, you will be able to change properties and add/remove controls. To edit a control, switch to the Edit mode and click on in the right upper corner of the control and choose "Edit". The Editor parts added to the EditorZone will now become visible. To retain a closed control, switch to Catalog mode and navigate to Page Catalog, you will be able to display the control in the WebPartZone of your choice.