I have a problem with the following code in an ASPX page:
The function runs twice. Once from the inside and then it gets called again from inside itself. Simple add a return statement at the end.
This worked perfectly for me.