Steps to Implement inputbox on Button Click in C#.Net
1>Drag a Button on Form
2>Right click on project in Solution Explorer and Click on Add Reference
3>Select Microsoft.VisualBasic
4>Click Ok
Then come to code and write the below code:
using Microsoft.VisualBasic;
private void button1_Click(object sender, EventArgs e)
{
//string myValue = Interaction.InputBox("Enter Name","Input Box","Name Here", 100, 100);
//MessageBox.Show(myValue);
//or
string message, title, defaultValue;
string myValue;
// Set prompt.
message = "Enter a value between 1 and 3";
// Set title.
title = "InputBox Demo";
// Set default value.
defaultValue = "1";//Display message, title, and default value.
myValue =Interaction.InputBox(message, title, defaultValue,100,100);// If user has clicked Cancel, set myValue to defaultValue
if (myValue == "")
{
myValue = defaultValue;
MessageBox.Show(myValue);
}
else
{
//MessageBox.Show(myValue);
}
}

mark courtPosted Mar 31, 2016, 5:17 PM EDT
To fix the 'Interaction' you need to ADD a Reference. Right click Reference > Add reference > Click on .NET and choose Ms Visual basic. Then you can debug this code which works in c#. YOUR WELCOME!
Vipin SaxenaPosted Jun 29, 2015, 11:05 PM EDT
The type or namespace name 'Interaction' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
M MeenakshiPosted Apr 9, 2013, 11:27 AM EDT
the above code for inputbox is not working at my site. it is showing an error to the "interaction". it is showing me an error as "the name 'interaction' does not exist in the current context". now what else i have to write in my project-code to make it execute successfully...??? please suggest me as early as possible..
rohol aminPosted Nov 14, 2012, 6:53 AM EST
Thank for your source code.
Jilani ShiakhPosted Jul 24, 2010, 10:08 PM EDT
Dear Sushant, this is very nice implementation.