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 / Building Controls / May 2006

Tip: Looking for answers? Try searching our database.

Extending System.Web.UI.Page with new properties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christophe Peillet - 23 May 2006 08:09 GMT
I am trying to extend the Page class with a new BasePage class containing
common elements required by all of our web pages.  By itself this is a very
simply task, but whenever I add properties to the BasePage class they appear
in the Intellisense tool on the code-behind but not on the property explorer
in the visual layout tool, which is where I need to see them the most.

I am using MasterPages in the projects (and have also created a
BaseMasterPage class that extends MasterPage), and have the same problem.  
Does anyone have any idea why the TitleResourceKey property does not show up
in the property explorer with pages that implement BasePage?  I have even set
the Browsable attribute of the property to true (this property is normally
only useful when set to false, since true is the default value), also to no
avail.

A snippet of my BasePage class:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel;
using System.Reflection;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CompanyName.EEE.Web.Common.Localisation;

namespace CompanyName.EEE.Web.Common
{
   /// <summary>
   /// Adds common functionality to all CompanyName Support Pages.
   /// </summary>
   public class BasePage : Page
   {
       #region Private Fields

       private string m_titleResourceKey;

       #endregion

       #region Public Properties

       /// <summary>
       /// Gets or sets the Title resource key.
       /// </summary>
       /// <value>The Title resource key.</value>
       /// <seealso cref="T:ILocalisable"/>
       /// <seealso cref="T:CompanyNameLocalisationKey"/>
       /// <seealso cref="T:LocalisationManager"/>
       /// <seealso cref="T:IResourceEngine"/>
       [EpsonLocalisationKey("Title")]
       [Bindable(true)]
       [Description("The resource key used when translating the page
Title.")]
       [Category("Appearance")]
       [Browsable(true)]
       public string TitleResourceKey
       {
           get
           {
               return m_titleResourceKey;
           }
           set
           {
               m_titleResourceKey = value;
           }
       }

       #endregion
   }
}
Steven Cheng[MSFT] - 23 May 2006 10:57 GMT
Hi Christophe,

Thank you for posting.

As for this issue, I've also seen your former thread in the aspnet main
newsgroup. As I mentioned in that thread, the design-time attribute or
service interfaces in VS IDE are provided for web server controls rather
than template based controls. So for custom properties on Page class or
Usercontrol's derived class, they can not utilize the design-time features
(provided for webserver controls). We can find that for aspx page, its
properties in the design-time propertyGrid are mapped to certain @Page
directive attributes or aspx inline html content, rather than the inner
text as webserver control, so they're not using the same implementation as
webserver control.

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Christophe Peillet - 23 May 2006 12:23 GMT
Steven:

Thanks, as always, for your comments.  Is there then no way to add a
property to the property explorer of an extended page at design time?  I'm
surprised this functionality isn't more easily offered, since it can be
useful in a variety of circumstances, and extending the page class is a
fairly common procedure for enterprise-level solutions.  How are the
properties that do get displayed set (such as Title) in Visual Studio (I
suppose I can use Reflector to look into this, but perhaps you know the
answer off the top of your head)?

Christophe

> Hi Christophe,
>
[quoted text clipped - 28 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 24 May 2006 08:27 GMT
Thanks for your response Christophe,

As for those displaying properties of "Page" class such as "Title", they're
directly persisted in the aspx template of the webform( in @Page directive
or in the html content...). Also, I think most of such operations are
supported by the "WebFormDesigner" class attached to the "Page" class and
this class is quite complex and there is no definite document on this.
Therefore, the page (or usercontrol)'s design-time support are quite
different from server controls and we haven't any means to customize it so
far. However, as for a good comments I suggest you submit it to the MSDN
feedback site so that the dev team can acquire such feedback:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

Regards,

Steven Cheng
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


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.