Subclass a class derived from WebControlWrapper

I’m trying to subclass a class derived from WebControlWrapper, but the framework returns an error:

“MySubclass.Name - This item does not exits MySubclass”

Is it possible to subclass it or I have to instance directly the original class?

Thanks.

[quote=117754:@Carlos Arzuaga]I’m trying to subclass a class derived from WebControlWrapper, but the framework returns an error:

“MySubclass.Name - This item does not exits MySubclass”

Is it possible to subclass it or I have to instance directly the original class?[/quote]

You are probably trying to get the name of the original class instead of the instance on your WebPage.

In a project I have a class named myHTMLArea, and on the WebPage an instance called myHTMLArea1. When I try to use myHTMLArea.Name I get the same error, but when I go myHTMLArea1.Name it works just fine.

No, there is not an instance at this point.

I’ve a class derived from WebControlWrapper (class1), then I subclass in the IDE a new class derived from class1 (class2).
I analize the project without instantiating class2 and the framework returns the error:

"class2.Name - This item does not exist class2"

I can’t see why not
But an example thats giving you this error attached to a bug report would be useful too

[quote=117764:@Carlos Arzuaga]No, there is not an instance at this point.

I’ve a class derived from WebControlWrapper (class1), then I subclass in the IDE a new class derived from class1 (class2).
I analize the project without instantiating class2 and the framework returns the error:

"class2.Name - This item does not exist class2"

OK. I was able to reproduce the problem.

I suppose it is a bug. I tried to add a string property Name bug the error still comes.

Maybe instead of creating a subclass you can duplicate the class instead ? I verified it to work.

Thanks Michel. Yes I verified it, but I prefer to subclass it becouse it’s a thrid party control and It’s easy for me to update to new versions subclassing it.

I’ve filled a bug report (#34741) with an example, subclassing the jQueryCalendar from WebSDK examples. I verified that deleting the JavascriptNamespace constant of the original class and inserting it in the subclass the error dissapears, there is only a warning about it. Could it be that the error comes from here?

[quote=117780:@Carlos Arzuaga]Thanks Michel. Yes I verified it, but I prefer to subclass it becouse it’s a thrid party control and It’s easy for me to update to new versions subclassing it.

I’ve filled a bug report (#34741) with an example, subclassing the jQueryCalendar from WebSDK examples. I verified that deleting the JavascriptNamespace constant of the original class and inserting it in the subclass the error dissapears, there is only a warning about it. Could it be that the error comes from here?[/quote]

I did what you do, moving the namespace constant to the subclass. It does remove the name error from the analyse, but then when I run in the IDE my test project gets stuck at “Launching …”.

If the workaround runs at your place, fine, but it looks fragile.

[quote=117782:@Michel Bujardet]I did what you do, moving the namespace constant to the subclass. It does remove the name error from the analyse, but then when I run in the IDE my test project gets stuck at “Launching …”.

If the workaround runs at your place, fine, but it looks fragile.[/quote]

It works fine for me on Windows 7, but I prefer to wait for how evolves the bug report. Thanks Michel.

Make the PRIVATE constants PROTECTED so they are available to subclasses & things should be OK

Not so much a bug but a requirement of every web control wrapper subclass is that they have those constants

And your subclass WOULD if they were protected - but they were private so effectively it didn’t have them because they were for the superclass only

Thanks Norman, works perfectly!

Keep in mind that every WebControlWrapper class or subclass must have a unique JavaScriptNamespace constant. We don’t currently enforce this, but we plan to.

Greg, then It’s preferable to shadow the JavaScriptNamespace constant in the subclass, and give it another Namespace value?

That’d be a workable option
If you make the one in the super private and the same for the sub then you will get the compilation error if you forget to set it on yet another sub

So if the JavaScriptNamespace is ‘Example’ in the class, it should be something else in the subclass, such as ‘Example2’ ?

Yes. If you haven’t done so, read the WebSDK docs regarding namespaces. We ask that you register your base name so we can avoid conflicts.

I just sent my request. Thank you.

Thanks for all your help, I’m going to send the mine.