Determining which button is pressed in a Web dialog

If I create a web message dialog in code:

Var md As new WebMessageDialog
md.Title = "Title Text"
md.ActionButton.Caption = "Quit"
md.CancelButton.Visible = False    
md.AlternateActionButton.Visible = True 
md.AlternateActionButton.Caption = "Don't Quit"
md.Message = "Message text"
md.Explanation ="Explanation text"

then I can get the dialog to display as expexted, but how do I determine which button has been pushed? The show function doesn’t return a value.


You need to implement the ButtonPressed event of the WebMessageDialog. See here for more info:

When the button pressed event fires, the button they pressed is passed in.

Thanks - but I can’t find in the documentation how to do that from code. How can I implement an event from code (rather than by hand building each dialog in the IDE)?

Best regards

Use AddHandler.

  1. Right-click on WebMessageDialog in your code and select Add Method > From Event

  2. It’ll add a method to the page with the correct signature.

  3. Back in your code just after declaring your variable, put the following, replacing with the name of the method created in step 2.

AddHandler md.ButtonPressed, AddressOf <method>

  1. Inside the method that was created, at the very top, put:

RemoveHandler obj.ButtonPressed, AddressOf <method>

It’s very important to call the remove version to prevent memory leaks.


Excellent! Thanks so much for the pointers.

Best regards