Showing another Webpage in Openning-Event of another webpage fails

If there are 2 WebPages in a project. is called in the opening event of WebPage1, then WebPage1 is displayed at the end.
This is definitely not intended.
In this case, the rendering of WebPAge1 would have to be cancelled and WebPage2 would have to be delivered.
Of course it works in shown, but that is not nice.

Did you close webpage1 or did you just let them both race to the browser?

I did both. closing results in an empty page, because it is not rendered.

That was my only theory. I think Ricardo knows about this one. I did, but thought it was fixed now. Search through issues for a ticket.

It behave different than Desktop.
WebPage2 should show but the problem is that on Desktop there are actually 2 windows and on Web we have only 1 WebPage visible, in the end I’m not sure exactly what we should get.

Anyway, this works on a small test (opening event of WebPage1):

me.Style.Value("display") = "none"
Webpage2.Style.Value("display") = ""

Webpage2 shows and not Webpage1. Not sure if this helps you as changing Style Values directly may cause problems. You may need to design your app around this.

FWIW, if your issue is that you want to show something on WebPage1 while the browser is loading WebPage2, then why not use a WebPagePanel, with the initial display graphics on WebPage1, then once the new contents is loaded, set the WebPagePanel.SelectedIndex = 1?

1 Like

This sounds like a bug, could you please open a new Issue?

That said, what’s the reason behind showing a page in the Opening event of another one? If you’re doing it to avoid displaying the default WebPage (for example, routing the user between a login page and a dashboard), then WebSession.Opening event could be a better place.


In my case it was a permissions level check and needing to load a different page instead. I found a workaround, but it interrupted the consistency of design.

In Opening it was basically (pseudo forum code to illustrate)

if Session.oUser = nil or (not Session.oUser.bIsAllowedToLoadThisPage) then
  var oLogin as new pgLogin


It was not just “are they logged in” it also included “do they have permission to”, so Session.Opening was not the right place and this applied to many pages with many permission levels.

1 Like

That makes sense, thanks.

I’ve just found this case that seems to be the same issue:

1 Like

There is a part needed to be authenticated. If the User comes to loginpage, it’ll be checked if there is a auto-login cookie and then the login is made without entering user/password.
This should only happen, wen going to the loginpage. Because Admins or Superadmins are able to login as normal user (without doing login / for debugging). In that case the cookie-login should not be made (otherwise the will be Superadmin all the time).
Ok, it is possible to check all that in, but that is much more code and it is a second place to have some login code. I want to have my Code clean and “in place”. So everything that hast Du do with Login is placed on the LoginPage (or in the Login Folder). Of course, I can put a class in the login-folder, and call that Class from, but then it is not clear where this class is called. I don’t like coding this way.

At the moment, I do this in the shown event, but that is not nice because the page is delivered to the user and then the next one get’s loaded.