Read Data Of WebContainer Text Fields

Hi,

I have created a webcontainer named ccLogin with two text fields and one button. The web container is loaded on the Open event of the main webpage on this way:

  Dim wcLogin As New ccLogin
  
  'Load login container (wp is a parameter defined into the method as webpage)
  wcLogin.EmbedWithin(wp, 0, 0, wcLogin.Width, wcLogin.Height)

How can I to read or get the info of the text fields ?

If I try to use the ccLogin (webcontainer) directly reading textfields from other method, I get a message “Item does not exist” :

  dim Data(1) as String
  
  'Vars
  sData(0)=ccLogin.Textfield1.Text
  sData(1)=ccLogin.Textfield2.Text

And I can’t to create an instance of the webcontainer because the data of these textfields would be empty.

Someone can give me a suggestion …? What’s the best way to read data of webcontainer controls loaded by code ? How to know what’s the active webcontainer and read info of controls of that webcontainer …?

Thanks in advance.

Don’t DIM the webcontainer. Create a property on the webpage or a module, for instance wclogin as cclogin and do

wclogin = New cclogin

You will then use wclogin as reference to access the container’s controls.

Hi Michel,

Thanks for your reply. According to your suggestion, I have created a property into a main page with these especifications:
Name: wcLogin
Type: ccLogin
Scope:Public

From the method I have in a module, I included the code:

 dim wcLogin as ccLogin
 dim sData as string 

//Vars
  wcLogin=new ccLogin
  sData= wcLogin.Textfield1.Text
  MsgBox sData

But the result is an empty string, althought the textbox1 contains data.

If I use this code trying to access the property wcLogin created in the main page:

 dim sData as string 

//Vars
  sData= wpMain.wcLogin.Textfield1.Text
  MsgBox sData

I get the error “NilObjectException”.

I’m not sure if I have understood correctly your suggestion, or I’m doing wrong something. Do you have a little example or file to do that ?

Don’t do dim wcLogin as ccLogin

That creates a local wclogin that supersedes the property. It explains the nil object exception that you get.

Remove that line and you should be fine.

Michel many thanks,

I have created a method directly into the webcontainer with private scope that send parameters to other method and module. Now works fine.