Search code examples
javascriptuser-controlsgenexus

Javascript UC and UC properties


I have this UC:

this.show = function()
{

    ...

    var myvar = "Text of the var."  

    this.Property1 = myvar + "1";
    this.Property2 = myvar + "2";

    this.FontSize = 40;


    ///UserCodeRegionEnd: (do not remove this comment.)
}

And this event in the UC:

enter image description here

And I get this result:

enter image description here

So my question is, why the properties do not have the value I assign in the method show()?


Solution

  • The problem is that you are expecting the values of the properties to be avaiblable when the page is loaded for the first time. The values of the properties modified in the show method are available after a user event is fired (for example, Enter).

    To solve the problem, insert a button in your web form, bind it to the Enter event, and move the code inside the Load event to the Enter event.