ControlID for webpage objects

I find it somewhat frustrating that when I check the browser console I can’t tell what controls are firing events because the objects have a random ID that is reported as the source of the event. I wonder whether it might be possible to optionally prepend or append some kind of code to an otherwise random ID. I’m thinking something like a 3-character code as a property of the object which would then become the first 3 characters or last 3 characters of the control ID. If something like that were possible it could uniquely identify a particular object from within the console, which would make debugging a lot easier (for me at least). Of course I’d be open to any idea which could give a similar result.

This adds a field “myName” to Button1 in the DOM.

You can use this technique to do what you want, without messing up with the controlID.

[code] dim myName as string = “Button1”
dim js as string
js = “document.getElementById(’” + Button1.ControlID + “’).setAttribute(‘myName’, '” + myName + “’);”

self.ExecuteJavaScript(js)[/code]

You can subclass all controls and do this in their shown event, or it you just need to debug a few, in the WebPage Shown event.

Note that if you subclass, you can directly use me.Name instead of the myName as string variable.

1 Like