Question

I want to create custom control which will be able to reuse using Script#

 public class HallView : Element
 {
    public int HallId;

    public HallView(): base()
    {
       this.AddEventListener("click", Click, false);
    }

    private void Click(ElementEvent e)
    {
       Script.Alert("Click " + this.HallId);
    }
 }

then reuse HallView like

   HallView hall = new HallView();
   hall.ClassName = "hall clickableSection";
   container.AppendChild(hall);

The problem is I cannot call any Element's methods, even can compile and build Object does not have method addEventListener

or

Object does not have method appendChild

Was it helpful?

Solution

The DOM doesn't support extending existing element types... so don't try it. Unspecified results.

You also can't new up DOM elements. You need to use document.createElement.

There are other ways to create the equivalent of custom controls - the most common of which is to create a jQuery plugin. There is a script# library project template for creating such plugins.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top