我想在MessageBox中顯示我的驗證錯誤消息。我有四個文本框和一個按鈕控件。當我單擊按鈕控件時,沒有文本的文本框將顯示在MessageBox中。我已經差不多完成了這一步,但問題在於當我單擊按鈕時,MessageBox以最小化窗口打開。所以最終用戶很難實現。我想在點擊按鈕時向用戶顯示MessageBox。如何在ASP.NET Web應用程序中顯示Windows.Form.MessageBox?
這裏是我的代碼,在按鈕單擊事件
ErrorMsg="";
if (TextBox1.Text == "")
{
ErrorMsg += "Name is required!";
ErrorMsg += "\n";
}
if (TextBox2.Text == "")
{
ErrorMsg += "Address is required!";
ErrorMsg += "\n";
}
if (TextBox3.Text == "")
{
ErrorMsg += "Phone No. is required!";
ErrorMsg += "\n";
}
if (TextBox4.Text == "")
{
ErrorMsg += "City is required!";
ErrorMsg += "\n";
}
if (ErrorMsg.Length == 0)
{
//Some Code
}
else
{
MessageBox.Show(ErrorMsg, "Existing Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
在此先感謝...
到目前爲止,我使用了驗證控件。但用戶要求我顯示爲一個MessageBox。 – thevan 2011-01-24 07:35:45
@thevan,那麼你將不得不向用戶解釋ASP.NET和WinForms不是同一件事,而他所要求的僅僅是沒有意義,因爲ASP.NET應用程序在服務器上運行。由於您似乎有一個客戶端,其中有一些有趣的*期望:-) – 2011-01-24 07:37:00