Cannot assign a value to this property Name error!

I have a web application I’m trying to create a class based on the ftp plugin that Andrew Lambert wrote. However when I duplicate the class and point it to the superclass the project works compiles and runs, but when i save the project and reopen it I get the following error

VehicleDetailsPage.Client1.Name Layout (property name) Cannot assign a value to this property Name

I’ve no idea why is it a bug?

Is Client1 a property of the web page?

no Greg its just in controls

Ah. Okay, the problem is that classes dragged onto a WebPage, WebDialog or WebContainer must be a subclass of WebControl. If they’re not, you get the error you describe.

here are two ways you might handle this:

  1. Add the ftp class to the page as a property and direct it’s events using AddHandler.
  2. Wrap the ftp class in a subclass of WebControlWrapper. You’ll need to do a little reading about the WebSDK, but you’ll be able to get away with just a basic tray only control.

Yeah, that’s what I thought. It’s a known bug, and two of the workarounds are listed above.

Greg thanks for that I take it I just add it as a property i.e. name Client1 as ftp.Client but then how do I use the AddHandler

sorry I’m new to xojo

Chris

Not a problem. It’s something that we need to fix, but finding a way that doesn’t break people’s existing projects has been a bit challenging.

added it as a property but now need to know how to do the AddHandler bit

Let’s say your ftp class has an event called FileSent:

  1. Create a method on the webPage called FTPFileSent (the name doesn’t matter)
  2. Set the parameters the same as the event and then insert a parameter at the start to represent the instance that is firing the event. If the original signature was:
FileSent(f as FolderItem)

Then the method’s signature would be

FTPFileSent(myFTP as FTP.Client, f as FolderItem)
  1. right after the code where you create the instance, you’ll need to add lines that look like this:
AddHandler Client1.FileSent, AddressOf FTPFileSent

[quote=144097:@Greg O’Lone]Let’s say your ftp class has an event called FileSent:

  1. Create a method on the webPage called FTPFileSent (the name doesn’t matter)
  2. Set the parameters the same as the event and then insert a parameter at the start to represent the instance that is firing the event. If the original signature was:
FileSent(f as FolderItem)

Then the method’s signature would be

FTPFileSent(myFTP as FTP.Client, f as FolderItem)
  1. right after the code where you create the instance, you’ll need to add lines that look like this:
AddHandler Client1.FileSent, AddressOf FTPFileSent

Gregg thanks again I take it I only have to do this for events that I call from the webpage?

You do this for events that you want to implement. Methods are the things you call, and no, you can not use AddHandler with those. Just call them directly on your class.

Gregg Thanks again im getting

NilException error on this now

VehicleDetailsPage.Client1.Username = “webstor1”

any idea why?

Sounds like you’re not creating the instance. Right before you do the AddHandler call, make sure you put

Client1 = New FTP.Client

Greg,

getting there now however I don’t call any events from the webpage but when i call the following method its not opening the ftp connection

Client1.connect

Im sure its down to eventhandlers but have no idea it doesn’t throw any errors either

If i dont fire any events within the webpage i take it i dont need the addHandler calls?

Regards

Chris

I’d put a breakpoint on the Client1.Connect method and step your way through the code at that point. Maybe there’s some other properties that are not set up properly?