[Gambas-user] How to load a new page on gb.web by code
T Lee Davidson
t.lee.davidson at gmail.com
Wed Sep 20 00:48:08 CEST 2023
On 9/19/23 16:10, Mayost Sharon wrote:
> Maybe I don't understand the process of the gb.web, but my expectation was that every page when I click on submit buttons that
> are supposed to perform an action should have been conducted on the page itself that was loaded, unless I specifically say in
> the action to go to another page
That's not exactly how HTML forms work.
First, the page is sent to the browser that displays the form with its submit button. If the form has no 'action' attribute, as
in this case, the browser submits the form to the very same URL. So, the Gambas script is called again, and the page HTML source
is sent to the browser again.
And, since the code calls Webpage1.Render and then Quits, Webpage1 is rendered as the only content of Main.webpage.
> What I currently understand is that every time he performs an action he always returns to the main page
This is because there is also no 'action' attribute in the form on Webpage1. So, the browser submits that form to the same
Gambas script which, by default, renders Main.webpage.
It seems that we should be able to have the browser fetch Webpage1 by using the relative URL: w7.gambas/Webpage1.webpage. But,
that doesn't work.
Also, Response.Redirect doesn't seem to work; at least not the way I am trying it. I put the following code at the very top of
Main.webpage, and no redirect occurred:
(This was on an Apache server trying with Firefox and Chromium.)
Hopefully, Benoît can clarify why this isn't working the way it seems it should.
More information about the User