Rushikesh Deshpande
Rushikesh Deshpande

Reputation: 93

How to make a simple popup box in Visual C# 2015 web application?

As I know I can make a popup window in vs 2010 using MessageBox.Show() method. But it is not available in VS2015, so I want to know if there is any simple alternative to it. I am creating a web application using visual studio C# and no class System.Windows.Forms is available as given in the link.

Upvotes: 0

Views: 1717

Answers (2)

timv
timv

Reputation: 3366

I suspect you already have an answer to this but here is how I solved a similar problem using VS2015.

    var messageDialog = new MessageDialog("Smaller Text Message", "Large Text Message");

    messageDialog.Commands.Add(new UICommand("Try again", new UICommandInvokedHandler(this.emailRetryPasswordRetrieval)));
    messageDialog.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(this.emailRetryPasswordRetrieval)));

    await messageDialog.ShowAsync();

Then in the method emailRetryPasswordRetrieval

private void emailRetryPasswordRetrieval(IUICommand command)
    {

        if (command.Label.Equals("Try again"))
        {
            mymethod();
        }
        if (command.Label.Equals("Cancel"))
        {
            anothermethod();
        }
    }

and dont forget to add:

using Windows.UI.Popups;

Upvotes: 0

Shaharyar
Shaharyar

Reputation: 12439

It is available in all versions of .net(including latest .net 4.6), see here.

But it is for Desktop application(winform/WPF) only, not available in web or Console application.

Upvotes: 1

Related Questions