Customizing Web Parts - hiding prop in edit mode?
Update:
private string _catalogIconImageUrl = "http://hostname/images/favicon.ico";
[WebBrowsableAttribute(false),
Category("HIDDEN"),
Personalizable(PersonalizationScope.User),
WebDisplayName("Catalog Icon Image url"),
WebDescription("Something")]
public string CatalogIconImageUrl
{
get
{
return _catalogIconImageUrl;
}
set
{
_catalogIconImageUrl = value;
}
}
with the above code, it does not show the image and also when i click on edit the webpart i still able to see the catalogIconImageUrl prop in edit mode
Update end
I've declared the property CatalogIconImageURL in the .Webpart
file as follows:-
</pro开发者_高级运维perty>
<property name="CatalogIconImageUrl" type="string">images/company/companylogo.jpg</property> //sample path...
</properties>
if I click on the Advanced Web Part Gallery as shown below in the screen shot, i able to see that property in editable
so my question is, is there a way i can hide this property when user edit the web part? "Catalog Icon Image URL"
You can set the WebBrowseable
or Browseable
attribute to false
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webbrowsableattribute.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.browsable.aspx
Update:
It is also marked as virtual. This property is a OOTB property in WEb Part class. See here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart.catalogiconimageurl.aspx
You should override this property and then set the above attribute to false
/// <summary>
/// Catalog Icon
/// </summary>
[Category("Properties")]
[DefaultValue("")]
[Personalizable(PersonalizationScope.Shared)]
[WebDisplayName("Catalog icon image URL:")]
[WebDescription("Enter the WebPart title.")]
[XmlElement(ElementName = "CatalogIconImageUrl")]
[WebBrowsable(false)]
public override string CatalogIconImageUrl
{
}
精彩评论