How to call window.alert(“message”); from C#?

后端 未结 10 2337
春和景丽
春和景丽 2021-02-07 05:18

I have my own exception based on some condition and want to raise an alert when control comes in this catch block

catch (ApplicationException ex)
{
    //want t         


        
10条回答
  •  臣服心动
    2021-02-07 06:14

    You can try this:

    Hope it works for you..

    `private void validateUserEntry()
    {
        // Checks the value of the text.
        if(serverName.Text.Length == 0)
        {
        // Initializes the variables to pass to the MessageBox.Show method.
        string message = "You did not enter a server name. Cancel this operation?";
        string caption = "Error Detected in Input";
        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
        DialogResult result;
    
        // Displays the MessageBox.
        result = MessageBox.Show(message, caption, buttons);
        if (result == System.Windows.Forms.DialogResult.Yes)
        {
         // Closes the parent form.
            this.Close();
        }
        }
    }` 
    

提交回复
热议问题