364,085 Members | 5432 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

How to display message box using c#

nirmalsingh
100+
P: 214
what are the things i shoul import?.. and how could i display a message box in c#? sample code will help me a lot.....
Dec 14 '06 #1
Share this Question
Share on Google+
7 Replies


sandeepk84
P: 97
what are the things i shoul import?.. and how could i display a message box in c#? sample code will help me a lot.....
hi...
u can have messageboxes displayed in C#...
for that u have to import System.Runtime.InteropServices
like
using System.Runtime.InteropServices;

then within ur class, write

[DllImport("User32.dll")]
public static extern int MessageBox(int h, string m, string c, int type);

now u can easily call the function MessageBox()....
Hope this will help u..
thanks...
Dec 14 '06 #2

josephkind
P: 2
If it is windows applications you can directly call the function MessageBox.Show("hello");

The above function
if it is webapplication you have to use javascript fumction to get messageBox
I hope it is clear.
Dec 16 '06 #3

sunilkundekar5
P: 3
hi...
u can have messageboxes displayed in C#...
for that u have to import System.Runtime.InteropServices
like
using System.Runtime.InteropServices;

then within ur class, write

[DllImport("User32.dll")]
public static extern int MessageBox(int h, string m, string c, int type);

now u can easily call the function MessageBox()....
Hope this will help u..
thanks...
I have tried this code but it's not working, reply plz....why?
Jan 2 '07 #4

sunilkundekar5
P: 3
hi...
u can have messageboxes displayed in C#...
for that u have to import System.Runtime.InteropServices
like
using System.Runtime.InteropServices;

then within ur class, write

[DllImport("User32.dll")]
public static extern int MessageBox(int h, string m, string c, int type);

now u can easily call the function MessageBox()....
Hope this will help u..
thanks...
I wants to use skin file in c#. Wheather this fascility is available in the c# plz... reply.
Jan 2 '07 #5

sandeepk84
P: 97
I have tried this code but it's not working, reply plz....why?
please check ur code once more...
have u called d MessageBox function wid d rigt no. of parameters?
also remember to include

[DllImport("User32.dll")]
public static extern int MessageBox(int h, String s, String s1, int type);

in d global variable declaration section( within class, out side member functions)

then u must get d function ready 2 b called...
u can call it by having arguements 'h' and 'type' as 0...
s is d msg to b displayed and s1 is the title...give some strings for those params...

hope dis will help u..
thanx and rgrds...
sand...
Jan 2 '07 #6

sandeepk84
P: 97
I wants to use skin file in c#. Wheather this fascility is available in the c# plz... reply.
Yeah...it's possible...u can have d skin files added in ur pjt...
u can put the skin files in d " App_Themes" folder...
thanx and rgrds..
sand...
Jan 6 '07 #7

DhananjayIndia
P: 2
what are the things i shoul import?.. and how could i display a message box in c#? sample code will help me a lot.....
If you are using c# in asp.net then make javascript function in codebehind and register it with codebehind and call where u need it.
Example:-
private void MsgBox(string msg)
{
string showMsg = "<script language='javascript'>" +
"alert("+msg+");</script>";
RegisterStartupScript("ds",msg);
string str = "<script language='javascript'>" ;
str = str + "alert('" + msg + "' )" ;
str = str + "</script>";
RegisterStartupScript("ds",str);

}

Dhananjay Singh
Jan 6 '07 #8

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework c# messagebox messagebox messagebox c# using messagebox