none
Input Message Box in C#?

    Question

  • Is there any control like an Input Message Box (users of VB would recognize this)

    I need a pop-up in the same form (pop-up not being a seperate form or a MDI child)  for the Login Id and password?

    Any Suggestions?

    thx in advance,

     

     

    Wednesday, November 01, 2006 3:22 AM

Answers

  • Believe it or not but this question is fairly common, especially coming from those who have previous experience with Visual Basic.  Unfortunately C# does not have anything like what you are after, but the beauty of .Net is that you are able to access methods/functions from other certain languages.

    In order to do this you need to Add a Reference to Microsoft.VisualBasic.dll.  Once you have done so you will have access to Microsoft.VisualBasic.Interaction.InputBox.  Below is an example of its use:

    Microst.VisualBasic.Interaction.InputBox("Did you know your question goes here?","Title","Default Text");

    You are also able to specify the x and y coordinates of the InputBox in the next two parameters.

     

    Hope this helps

    Wednesday, November 01, 2006 5:26 AM

All replies

  • Believe it or not but this question is fairly common, especially coming from those who have previous experience with Visual Basic.  Unfortunately C# does not have anything like what you are after, but the beauty of .Net is that you are able to access methods/functions from other certain languages.

    In order to do this you need to Add a Reference to Microsoft.VisualBasic.dll.  Once you have done so you will have access to Microsoft.VisualBasic.Interaction.InputBox.  Below is an example of its use:

    Microst.VisualBasic.Interaction.InputBox("Did you know your question goes here?","Title","Default Text");

    You are also able to specify the x and y coordinates of the InputBox in the next two parameters.

     

    Hope this helps

    Wednesday, November 01, 2006 5:26 AM
  • thx a lot !

     

    • Proposed as answer by Bravo2007 Wednesday, November 09, 2011 4:52 PM
    Wednesday, November 01, 2006 7:56 AM
  • Although I recommend using of VB old style.  http://www.codeproject.com/useritems/novbruntimeref.asp

    How much does it cost you to create a new class deriving Form with few properties: Title, DefaultText, Value, etc?

    Wednesday, November 01, 2006 11:04 PM
  • HI,
     
    U can try out this thing.........
     
     

    Response.Write("<script>alert('Enter Your  Message Here')</script>");

    • Proposed as answer by Marc Bollinger Wednesday, January 16, 2013 9:48 PM
    Wednesday, November 08, 2006 12:17 PM
  •  

    Just add the reference "Microsoft Visual Basic .NET Runtime" to your project.

    you needs to import "using Microsoft.VisualBasic;"

    then try to access the inputbox method.

    For ex:-

    string x = Interaction.InputBox("hi","hello","nothing",10,10);

    MessageBox.Show(x);

    Thursday, November 09, 2006 11:05 AM
  • What I have is a form with a textbox on it with a TextValue property. Everytime I want to get some input from the user I just display the form and then get the textvalue back.
    Thursday, November 09, 2006 11:13 AM
  • I have tried
    Microsoft.VisualBasic.Interaction.InputBox
    and its working fine.

    Well, what if I want to take login information like email and password and a link say "forgot your password" and buttons like signin or reset.

    Is there any method for that.
    If not how can I customize my  InputBox for these.

    Regards


    Tuesday, March 04, 2008 7:46 AM
  •  

    Satish an easy way you can implement this is by adding another form with the required controls to your project.

    Set the height and width property of the form so as it appears as a pop-up message box.

     

     

     

     

     

     

     

    Tuesday, March 04, 2008 8:29 AM
  • Thank you. It help me a lot
    Thursday, January 21, 2010 5:39 PM
  • Here is a more detailed solution for calling a form.  Sorry, this is in c#.

    Step 1 - Create a new Windows form
    Add your labels and the User/Password textboxes to the form
    Add an "OK" button and set the "DialogResult" property to "OK".

    Step 2 - Add the getters and setters code to the new form:

    public string UserName
    {
     get { return textBoxUserName.Text; };
     set { textBoxUserName.Text = value };
    }
    public string Password
    {
     get { return textBoxPassword.Text; };
     set { textBoxPassword.Text = value };
    }
    

    Step 3 - In your main form code:
    Declare the form class like:
    private PasswordForm _PasswordForm = new PasswordForm;

    Step 4 - In your main form code:
    Call the form (like a dialog):

    Dialog Result dialogResult = _PasswordForm.ShowDialog(this);
    if (dialogRusult == DialogResult.OK
    {
      //get user/password values from dialog
    }
    

    I hope this helps. 

    ~ Jeff

     

    Thursday, November 11, 2010 5:21 PM
  • Make your own messagebox like jeff mentioned above.. Then, in the future you can add/change functionallity at will... Using Message/Input box may work for you now, but what about your next project?

    Im just saying...

    Thursday, November 11, 2010 6:27 PM
  • Thanks .
    Wednesday, October 26, 2011 2:26 PM
  • Thanks, it helps me too- a lot.
    Wednesday, May 23, 2012 5:14 PM
  • Thank you, this really help me :D I didn't know how to use the property "DialogResult" from a Form.
    Friday, December 13, 2013 11:28 AM