MessageBox in C# showing error

Sudha picture Sudha · Apr 1, 2013 · Viewed 7.4k times · Source

I was attempting to add MessageBox.Show(Message); and it was not found in my C# .net web application (button click method and also in Page_Load).An error showing like

'The name 'MessageBox' does not exist in the current context'

Do I need to add any assembly reference for this? (I am using .net framework 4). Is there any alternative method for this?

Answer

slugster picture slugster · Apr 1, 2013

The key words in your description are

web application

This functionality is only available in client (WinForms, WPF) based applications, not ASP.NET. To do this in a web app you will need to use Javascript, as illustrated in this previous Stack Overflow question.