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);
}
}