How to display message in c sharp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leo sajjad
    New Member
    • Feb 2009
    • 4

    How to display message in c sharp

    Dear All,

    I am looking for code to display message box in c sharp language and guide line if any other requirement regarding to display message i mean to say that any class or namespeacing is required.

    Thanks

    Sajjad Ali
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    Hi

    Well I suppose we have these kinds of questions at some stage, the code is pretty self-explanatory so I will give it to you and you can read up about it using Intillisense.

    Code:
    System.Windows.Forms.MessageBox.Show("Text goes here");
    or to make things easier just type mbox and press <TAB> twice

    This method has a huge amount of overloads and you can customize it a lot, so just play around with it.

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      In case of windows application you can make use of Message Box
      and in case of asp.net use javascript . Also you can google for ajax message box

      Comment

      • Leo sajjad
        New Member
        • Feb 2009
        • 4

        #4
        missing assembly

        I code like this given bellow for message but their is a error

        missing assemble or like some and the highlighlited windows word that what should i do

        global::System.Windows.Forms.MessageB ox.Show("Hello world");

        Thanks

        Comment

        • PRR
          Recognized Expert Contributor
          • Dec 2007
          • 750

          #5
          Add reference to System.Windows. Forms in your ( i am assuming here a console application) application ... If its a web project ... use javascript... as server side code cant execute on client side ...

          Comment

          • chrisranjana
            New Member
            • Feb 2009
            • 2

            #6
            C# message box

            Also here is a custom message box in C#


            Originally posted by Leo sajjad
            Dear All,

            I am looking for code to display message box in c sharp language and guide line if any other requirement regarding to display message i mean to say that any class or namespeacing is required.

            Thanks

            Sajjad Ali

            Comment

            • Leo sajjad
              New Member
              • Feb 2009
              • 4

              #7
              Hi,

              I am trying to compare data if user select date for birth date field then it will compare today's data and subtract it by 18 year if it is valid then process further other wise send Alert Message that you are not eligible.

              For this all what i have to do i am also searching it.

              Please do replay.

              Thanks

              Comment

              • cloud255
                Recognized Expert Contributor
                • Jun 2008
                • 427

                #8
                Your question doesn't seem to have anything to do with this thread. Please start a new relevant thread.

                As for calculating if the age is over 18 you could try:

                Code:
                DateTime MinimumBirthDate, SuppliedBirthDate;
                TimeSpan LegalAge = new TimeSpan();
                
                LegalAge = TimeSpan.FromDays(365*18); //to get 18 years
                
                MinimumBirthDate = DateTime.Now.Subtract(LegalAge);
                
                SuppliedBirthDate = new DateTime(1203, 8, 8); //Enter birthdate supplied by the user here
                
                if (MinimumBirthDate > SuppliedBirthDate)
                {
                      //over 18 code
                }
                else
                {
                     //under 18 code
                }
                Hope this helps

                Comment

                • xenoix
                  New Member
                  • Mar 2009
                  • 15

                  #9
                  I probably wouldn't have spoon fed him the answer, but point him on the right direction.

                  IE: what methods/procs to use etc

                  Comment

                  • Jeganath
                    New Member
                    • Apr 2009
                    • 8

                    #10
                    Hi Sajjad Ali,

                    If u did not find out the answer till now, try this...

                    using System.Windows. Forms
                    MessageBox.Show ("Test Message");

                    Comment

                    • Leo sajjad
                      New Member
                      • Feb 2009
                      • 4

                      #11
                      Message Display

                      Dear,


                      I have done this this problem was at the begining level of my coding with c#.

                      Well thanks i will ask you if i have any other problem with c # code.

                      Thanx

                      Comment

                      Working...