PDA

View Full Version : [CLOSED] Inheriting from Ext Component HTML property



jchau
Jan 20, 2015, 8:54 PM
I created a custom control that inherits from Ext.Net.Component. The control simply overrides the Html property to allow for HtmlEncoding for XSS prevention. I notice that with a normal Ext.Net.Component, when you update Html property during a direct event, it sends back script to update the UI. With my custom control, it doesn't. What governs that? Do I need to specify the same property attributes as in the base class?

my Custom control:



Public Class SafeComponent
Inherits Ext.Net.Component


Public Property DisableEncoding As Boolean


Public Overrides Property Html As String
Get
Return MyBase.Html
End Get
Set(value As String)
MyBase.Html = If(Me.DisableEncoding, value, System.Web.HttpUtility.HtmlEncode(value))
End Set
End Property
End Class


Base class Html property


[Meta]
[Description("An HTML fragment, or a DomHelper specification to use as the layout element content (defaults to '')")]
[DirectEventUpdate(MethodName = "Update")]
[ConfigOption("html")]
[Category("3. AbstractComponent")]
[DefaultValue("")]
[NotifyParentProperty(true)]
public virtual string Html
{
get
{
return this.State.Get<string>("Html", "");
}
set
{
this.State.Set("Html", (object) value);
}
}

Daniil
Jan 21, 2015, 1:43 PM
Hi @jchau,

When a property is updated during a DirectEvent or a DirectEvent, Ext.NET is looking for a DirectEventUpdate attribute.

[DirectEventUpdate(MethodName = "Update")]

If defined, it calls a method specified in the attribute. The method is supposed to generate some JavaScript code to update a property on client side.