Xojo2023r3: Self.ControlWithName not working for WebDialog

I work on conversion of a web app from Xojo2018 to Xojo2023r3.
I have following code that takes user input from several entry fields and popup lists into mParamList in order to send it back to the underlying web page to build query and fetch records into the list.

Var vName As String
Var vWebTextField As WebTextField
Var vDataPopup As DataPopup

For i As Integer = 0 To mParamList.LineCount
  
  vName = mid(mParamList.GetValue(i,0),2) + "Field"
  vWebTextField = WebTextField(Self.ControlWithName(vName))
  If vWebTextField = Nil Then
    //ignore
  Else
    mParamList.SetValue(i,1,vWebTextField.text)
  End If
  
  vName = mid(mParamList.GetValue(i,0),2) + "Popup"
  vDataPopup = DataPopup(Self.ControlWithName(vName))
  If vDataPopup = nil Then
    //ignore
  Else
    mParamList.SetValue(i,1,vDataPopup.SelectedRowText)  // 2023.12.07 <gp> replaced deprecated Text
  End If
  
  vName = mid(mParamList.GetValue(i,0),2) + "MatchPopup"
  vDataPopup = DataPopup(Self.ControlWithName(vName))
  If vDataPopup = nil Then
    //ignore
  Else
    mParamList.SetValue(i,2,vDataPopup.SelectedRowText)  // 2023.12.07 <gp> replaced deprecated Text
  End If
  
Next

The above code works in Xojo2018.
When running Analyzer menu on this WebDialog class I get 3 errors:
Error: Type “AuditedDataMonitorSearchDialog.AuditedDataMonitorSearchDialog” has no member named “ControlWithName”.

It looks like the “ControlWithName” on WebDialog is no longer working.
Question: what should I use instead?

Have you already checked if the Self.ControlWithName(vName) method is public?

I don’t think ControlWithName exists anymore in Web 2.
You may ask for a feature request to bring that back and in the meantime Iterate using Controls.

1 Like

Alberto, how do I iterate using Controls (I have been thinking about it but have no idea where to start). Can you post a snippet of the code that illustrates this?
Maybe there is some resource that shows this as well but so far I couldn’t find it.

Thanks in advance.

Did you look at the link I provided above? The documentation shows a couple of samples.

1 Like

Alberto, sorry, I have overlooked the link on Controls. I see the documentation shows the example under the WebView, this is probably why I didn’t find it as I was looking at WebDialog.
Thanks, I will go over this and see if I can incorporate this approach.

1 Like