I'm developing a C # to JavaScript converter and I'm in a bind when the code has a line of code like this:
((CONTROLE)sender).Atributo
Exemplo:((ImageButton)sender).ImageUrl
What is the corresponding JavaScript code?
I'm developing a C # to JavaScript converter and I'm in a bind when the code has a line of code like this:
((CONTROLE)sender).Atributo
Exemplo:((ImageButton)sender).ImageUrl
What is the corresponding JavaScript code?
See, in C #, you're saying:
((ImageButton) sender) .ImageUrl
- Grab the object "sender" and make a Cast pro type 'ImageButton'; - With the resulting object (which is an instance of ImageButton), get the ImageUrl property (which is part of the ImageButton type);
Well, javascript is a poorly typed language. This cast is unnecessary. If the object is of ImageButton type, the ImageUrl property will be there, without you needing the cast. It will suffice:
sender.ImageUrl.
If you need to check the cast, use typeof to check the instance class.