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.
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)?
Right-click on WebMessageDialog in your code and select
Add Method > From Event
It’ll add a method to the page with the correct signature.
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>
- 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.