Problem with SMTPSecureSocket events in Web App

My email program currently works and pops up a WebDialog that says “Request Sent” whether it was sent or not. I am trying to implement the events in the SMTPSecureSocket so it can display the error message if that were to happen.

I subclassed SMTPSecureSocket adding a string property, mSessionID, a constructor

Super.Constructor
mSessionID = Session.Identifier

Also added, event handlers for Error, MailSent, and ServerError that call the ShowDialog method and pass the message to be displayed and a method, ShowDialog

Private Sub ShowDialog(msg As string)
var Context As New WebSessionContext(mSessionID)
if Context<>nil then
var w As WebPage = Context.Session.PageWithName(“MainPage”,True)
for i as Integer = 0 to w.LastControlIndex
if w.ControlAt(i).Name = “MsgDialog” then
var c as WebControl = w.ControlAt(i)
var d As WebDialog1
if c IsA WebDialog1 then
d = WebDialog1(c)
for j as Integer = 0 to d.LastControlIndex
if d.ControlAt(j).Name = “laText” then
var c1 as WebControl = d.ControlAt(j)
if c1 IsA WebLabel then
var l As WebLabel = WebLabel(c1)
l.Text = msg
end if
d.Show
Exit SUB
end if
Next
end if
end if
Next
end if
End Sub

The code executes but the WebDialog never appears. I am thinking I am not using the Context properly. I have tried the “var w as WebPage” line with and without “Context.” and it makes no difference.

I had been using Xojo 2021r3.1 and experienced the problem reported. Just tried it with Xojo 2022r1 and it works fine.