ASP.NET
  Home arrow ASP.NET arrow Page 2 - Manipulating Web Parts in ASP.Net 2.0
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Manipulating Web Parts in ASP.Net 2.0
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2005-12-05

    Table of Contents:
  • Manipulating Web Parts in ASP.Net 2.0
  • Editing Web Parts
  • The Web Part Catalog
  • Web Part Connections

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Manipulating Web Parts in ASP.Net 2.0 - Editing Web Parts


    (Page 2 of 4 )

    By now you should be pretty comfortable with installing web parts in your web applications. If not, you’ll need to go back to my first article on the subject, located here. You should have a basic page up and running with a couple of web parts, and if you followed the tutorial, they’re most likely based on user controls. Here’s the final code we developed in the last tutorial:

    <%@ register tagprefix=”jc” tagname=”Weather” src=”weather.ascx” %>
    <%@ register tagprefix=”jc” tagname=”Stocks” src=”stocks.ascx” %>
    <%@ page language=”C#” %>

    <html>
    <head>
    <title>webparts tutorial</title>
    </head>
    <body>
     <form runat=”server” id=”Form1”>
      <asp:WebPartManager runat=”server” id=”myWebMgr” />
      <asp:WebPartZone runat=”server” id=”zone1” PartChromeType=”Title”>
      <CloseVerb text=”hide” />
      <minimizeverb text=”shrink” />
      <PartStyle BackColor=”#CCC” />
      <ZoneTemplate>
     <jc:Weather runat=”server” id=”myWeather” />
     <jc:Stocks  runat=”server” id=”myWeather” />
    </ZoneTemplate>
      </ asp:WebPartZone>
     </form>
    </body>
    </html>

    This will display the weather and stock user controls, but with all the added functionality and visual characteristics of a standard web part. The functionality includes being able to minimize, close, and move a web part within a page.

    All visual characteristics are of course customizable, by both the developer and the end user. In the last article, we saw only how the programmer determines the visual aspects. But now I’ll show you how the end user can modify these, at run time. They can also make modifications to more than just the display; they can modify some of the behavior as well. Here’s the code you’d need to add to allow users to make their edits.

    <asp:EditorZone runat=”server” HeaderText=”Modify Settings”>
     <ZoneTemplate>
      <asp:AppearanceEditorPart runat=”server” />
      <asp:BehaviorEditorPart runat=”server” />
      <asp:LayoutEditorPart runat=”server” />
      <asp:PropertyEditorPart runat=”server” />
    </ZoneTemplate>
    </asp:EditorZone>

    You could further customize the actual rendering of the EditorZone by modifying the properties of the header and instruction text, as well as many other visual properties, but that is purely aesthetics, so I’ve trimmed down the example to purely functional pieces. What we’re most concerned with is the actual functionality provided by the four possible editor parts.

    Here’s an explanation of what each one does. (Note: not all need to be loaded; I simply placed them all in the code for the sake of explanation)

    1. Appearance Editor Part: modifies visual aspects such as width, title, text direction and border settings.

    2. Behavior Editor Part: determines whether personalization is supported, as well as editing and minimization.

    3. Layout Editor Part: determines frame style (normal vs. minimized), which zone the part is in, and the placement index within the specified zone.

    4. Property Grid Editor Part: custom properties. For this to show up, the web part must have public properties with the Personalizable and WebBrowsable attributes set.

    So once you’ve set up the Editor Zone and the contained template, each web part on the page will have an ‘Edit’ link attached to the list of options. Once clicked, the editor web part will appear exactly where you’ve coded it on the page. The default “Windows” buttons will appear in the footer, “OK”, “Apply”, and “Cancel”. Once again Microsoft has taken another step towards making the web a comfortable extension of what the vast majority of people are comfortable with in their operating system. This is a smart usability tactic.

    So once the user has made a change to their web parts’ settings, what needs to happen next? In other words: what do we as programmers have to develop to retain and restore each persons’ custom settings? Nothing. Absolutely nothing. If we’ve defined the personalization data store (next article), the personalization engine of the ASP.Net framework takes care of absolutely everything for us. Now you understand why I said web parts are going to be huge!

    More ASP.NET Articles
    More By Justin Cook


       · hope you enjoy the article!
       · Hello, Could you please provide an example of using custom provider for web...
     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT