Tuesday, January 17, 2012

Check if control exists by ClientInstanceName

In order to check whether a specific Devexpress control exists using javascript, you can use the ASPxClientUtils.IsExists method. If the control exists, the method words as expected. The problem rises when the control you are looking for doesn't exist as this will cause the error 'ReferenceError: myControl is not defined' in javascript. In order to solve this, first use the eval function to check whether the object exists and put it inside a try catch.
var obj = null;
try { obj = eval('myClientASPxGridview'); } catch (e) { }
if (ASPxClientUtils.IsExists(obj))
Link to ASPxClientUtils.IsExists documentation

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai.