Click here to Skip to main content
15,914,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my Asp.net website i want to display one message box. I tried
C#
System.Windows.Forms;

but am getting error message as;
C#
Error	2	The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
Posted
Updated 18-Dec-12 0:57am
v3
Comments
Anuja Pawar Indore 18-Dec-12 6:58am    
Added code block

This is possible in web forms
try this below code,
Message.show("");
but first add using System.Windows.Forms;
it will work.
 
Share this answer
 
Comments
Am Gayathri 18-Dec-12 7:18am    
Don't forget to add references also.
AshishChaudha 18-Dec-12 7:34am    
my +5!
Here is asp.net we do not have direct message box like windows forms but have confirmatation box or alerts message or popups using javascripts
Simple MessageBox functionality in ASP.NET[^]
ASP.NET MessageBox[^]
ASP.Net Message Box Alert Display[^]
here is simple example using javascript:
XML
<html>
 <head>
 <script>
 function display_alert()
   {
   alert("Hello! I am an alert box!!");
   }
 </script>
 </head>
 <body>

<input type="button" onclick="display_alert()" value="Display alert box">

</body>
 </html>


hope it helped

Happy Coding!!
 
Share this answer
 
v3
C#
System.Windows.Forms.MessageBox.Show
is for Windows forms not web forms

You can instead display an alert using javascript alert like
C#
Response.Write("<script type='text/javascript'> alert('your message here.')</script>");


Regards
Pawan
 
Share this answer
 
v2
Comments
Am Gayathri 18-Dec-12 5:04am    
Follow this, http://www.codeproject.com/Articles/7525/Simple-MessageBox-functionality-in-ASP-NET
Anuja Pawar Indore 18-Dec-12 6:56am    
Added code block
Rai Pawan 18-Dec-12 7:03am    
thanks Anuja
Anuja Pawar Indore 18-Dec-12 7:05am    
WC :)
Am Gayathri 18-Dec-12 7:16am    
This is possible in web forms also,
try,
put namespace on starting using System.Windows.Forms; then
use Message.show("");
There is no direct suport for message box in asp.net. One alternative is you can use javascript to display an alert.
 
Share this answer
 
Comments
Am Gayathri 18-Dec-12 5:03am    
Hi Nitin,
Follow this,
http://www.codeproject.com/Articles/7525/Simple-MessageBox-functionality-in-ASP-NET

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900