In this article you can find some frequently asked questions and its answers about User Controls.
No, Genexus.exe /install should only be executed when making changes to the UC structure, that is, when changing its properties or events.
On the other hand, if you just make changes to the javascript render file and the version of the control is not updated (tag <Version>0</Version> in .control file) then you need to delete file named <ucname>.<version>.VER from the web folder of your model and generate the object that uses the UC in order to get the files of your UC copied to the relevant folder eg: \web\<UserControlName>.
In order to get the container name at runtime you can use "this.ContainerName" inside the control's scope. E.g: var name = this.ContainerName;
In order to get a reference to the container control, you can use "this.getContainerControl()" inside the control's scope. E.g: var name = this.getContainerControl();
In many cases your user control will have to generate html like this: <a href="www.genexus.com" onclick="someFunction(z)">text</a>. In those cases you will want the onclick event to be attended by a function of your user control and not a global function (because that would be a problem if you have multiple instances of you control in the same web page). In those cases you will have to use the "this.me()" function within the scope of your user control as follows:
<a href="'+ this.MenuData[i].MenuURL + '" onclick="' + this.me() + '.JSDolphinItemClicked(\'' + this.ControlName + '\',' + i +');" title="' + this.MenuData[i].MenuDescription + '"> + this.MenuData[i].MenuTitle + '</a>
The example above is taken from the Dolphin Style Menu user control, downloadable here.
Use "this.IsPostback" to detect if the control is being loaded for the first time or not. E.g.:
~~
this.show = function()
{
if (!this.IsPostBack)
{
// draw control
}
}
The recommended way of subscribing user controls functions to the onload event is using:
gx.evt.on_ready( window,<myFunction>);
where myFunction is the function you want to subscribe to the onload event. Using this you will avoid possible incompatibilities that may happen when using different javascript frameworks (jquery, dojo, scriptaculous).