Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Personalizable()/WebBrowsable() issues in custom Web Part

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marc Woolfson - 14 Jun 2007 09:00 GMT
Hi,

I think this is a relatively simple problem, but it's starting to annoy me
quite a bit. I have two issues with a custom Web Part that I have created,
both related to property editing at run time using an EditorZone.

One of my web parts contains a control which displays information for a
particular (default) user. The user should have the ability to select an
alternate user whose information should be displayed in the control, and so I
have defined the relevant property as follows on the custom Web Part:

  [Personalizable(true), WebBrowsable(true), WebDisplayName("Scope code")]
   public string ScopeCode
   {
       get
       {
           return pr_scopeCode;
       }
       set
       {
           pr_scopeCode = value;
       }
   }

where pr_scopeCode is a private local variable.

To give the user a nicer front end than just a box for the code, I have
written a custom EditorPart to enable the users to be displayed and selected
from a drop-down list. *Problem 1*: although the drop-down list displays
correctly at run time, the value chosen by the user is not saved back to the
page. I can post the code for the custom EditorPart if that would be of
assistance.

I also have some other properties that I wish to allow the user to modify,
including the Title of the web part (I do not wish to open up all the
properties available in the AppearanceEditorZone). To implement this I have
used the code below:

  [Browsable(true), Personalizable(), WebBrowsable(),
WebDisplayName("Title")]
   public override string Title
   {
       get
       {
           return base.Title;
       }
       set
       {
           base.Title = value;
       }
   }

*Problem 2*: this, and the many other properties that I have marked as
'WebBrowsable' are not displayed in the EditorZone at run time at all.

Please can anyone suggest why these WebBrowsable properties would not be
available for editing at run time, and/or why changes in the custom
EditorPart are not saved back as personalised data? If I use the
AppearanceEditorZone or other pre-defined EditorZones, changes may be made
and saved back against the user successfully.

Thanks,

Marc
Marc Woolfson - 14 Jun 2007 14:36 GMT
Having done a bit more investigation I can see that *Problem 2* is actually
working correctly (rookie error - please don't ask) but *Problem 1* still
exists, seemingly only for static web parts. If I use the Catalog to add
another one of my custom web parts I am able to make the selection from the
drop-down list in the custom EditorZone, and it _is_ saved back to the web
part successfully. To resolve this, I removed the WebBrowsable attribute from
the ScopeCode property, as the 'old' value in the PropertyGridEditor was
overwriting the 'new' one selected from the custom Editor.

For the static web part, the value now seems to be saved and the contents of
the webpart updated as required when in *EditDesignMode*, but is _lost_ when
returning to BrowseDesignMode.

Any ideas? I would rather avoid adding all existing static web parts
dynamically in code.

Thanks,

Marc
GBelzile - 15 Aug 2007 21:52 GMT
Could I ask about the rookie error?  I must be doing the same because I just
can't see any of my custom properties.

Thanks,

> Having done a bit more investigation I can see that *Problem 2* is actually
> working correctly (rookie error - please don't ask) but *Problem 1* still
[quoted text clipped - 15 lines]
>
> Marc
GBelzile - 15 Aug 2007 22:40 GMT
Ok it really was a rookie error... my properties were not public.

> Could I ask about the rookie error?  I must be doing the same because I just
> can't see any of my custom properties.
[quoted text clipped - 20 lines]
> >
> > Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.