Extending System.Web.UI.Page with new properties

C

Christophe Peillet

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
}
}
 
S

Steven Cheng[MSFT]

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.



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

Christophe Peillet

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
 
S

Steven Cheng[MSFT]

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.



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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,042
Members
48,769
Latest member
Clifft

Latest Threads

Top