[Gambas-user] Return value from message box in webfrom application
Benoît Minisini
g4mba5 at gmail.com
Fri Jan 11 01:56:24 CET 2019
Le 10/01/2019 à 09:40, Michele V. a écrit :
> Hi to all
> How is possible le to know the selected button in message box used in
> webform application?
> No return value is provided by the function
>
>
> Thank you
>
> Michele
> -------------------------------------------------------------------------------------------------------------------------------------------
> Io scrivo da UBUNTU GNU/LINUX
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
gb.web.form (obviously?) does not allow any user (i.e. browser)
interaction inside a request.
The trick is the following: any control raises a "Message" event when a
message box has been opened from one of its event handler.
It works like that:
----8<------------------------------------------------------------------
' The remove button Click handler that opens the message box.
Public Sub btnRemove_Click()
Message.Question(("Do you really want to remove this file?"),
("Cancel"), ("Remove"))
' Execution continues here. The message box will be opened by the
' browser when the request is returned to it.
' You can even open other message boxes. But it's not a good idea.
End
' The Message event that gets the message box answer.
Public Sub btnRemove_Message((Source) As WebControl, Action As String)
If Action = ("Remove") Then
' Remove the thing
Endif
Catch
Message.Error("Unable to remove this thing!")
End
----8<------------------------------------------------------------------
You should note that there is another message in the btnRemove_Message()
method. It will call the btnRemove_Message() again! So you must be
careful to make the difference between the answers of the different
message boxes.
The last behaviour is not very clean, so if I find a different way to
get the message box answer, I will implement it. It could be based on a
message box identifier, I don't know yet.
Regards,
--
Benoît Minisini
More information about the User
mailing list