How to display message box using c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    How to display message box using c#

    what are the things i shoul import?.. and how could i display a message box in c#? sample code will help me a lot.....
  • sandeepk84
    New Member
    • Oct 2006
    • 97

    #2
    Originally posted by nirmalsingh
    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("User 32.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...

    Comment

    • josephkind
      New Member
      • Dec 2006
      • 2

      #3
      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.

      Comment

      • sunilkundekar5
        New Member
        • Dec 2006
        • 3

        #4
        Originally posted by sandeepk84
        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("User 32.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?

        Comment

        • sunilkundekar5
          New Member
          • Dec 2006
          • 3

          #5
          Originally posted by sandeepk84
          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("User 32.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.

          Comment

          • sandeepk84
            New Member
            • Oct 2006
            • 97

            #6
            Originally posted by sunilkundekar5
            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("User 32.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...

            Comment

            • sandeepk84
              New Member
              • Oct 2006
              • 97

              #7
              Originally posted by sunilkundekar5
              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...

              Comment

              • DhananjayIndia
                New Member
                • Jan 2007
                • 2

                #8
                Originally posted by nirmalsingh
                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='javas cript'>" +
                "alert("+msg+") ;</script>";
                RegisterStartup Script("ds",msg );
                string str = "<script language='javas cript'>" ;
                str = str + "alert('" + msg + "' )" ;
                str = str + "</script>";
                RegisterStartup Script("ds",str );

                }

                Dhananjay Singh

                Comment

                Working...