Click here to Skip to main content
Sign Up to vote bad
good
See more: C#
in my project i need to get input from user in messagebox with ok and cancel button..
i dont knw how to write code for that... can u help me
Posted 26 Jan '13 - 20:21


3 solutions

for windows forms-
InputBox in C#[^]
for webforms-
modal popup using jquery[^]
or use ajax modal popup extender
  Permalink  
Comments
Abhishek Pant - 27 Jan '13 - 9:04
Downvoter must see the link then only try to downvote.
Hi
 
You must design a win form that consist of OK and Cancel Buttons and a text Box.
and every time you need this message Box you must create instance from your form and show to end user.
 
Now, you can manage your user input text and do your act...
 
I hope it's helpful for you.
  Permalink  
You should try out this code:
 
<pre lang="cs">private void button1_Click(object sender, System.EventArgs e)
{
    // This test that the InputBox can handle more newline than one.
    InputBoxResult test = InputBox.Show("Prompt" + "\n" + "DDDD" +
                  "Prompt" + "\n" + "DDDD" +
                  "Prompt" + "\n" + "DDDD" + "Prompt" + "\n" + "DDDD" +
                  "Prompt" + "\n" + "DDDD" +
                  "Prompt" + "\n" + "DDDD"
                  ,"Title","Default",100,0);
 
    if( test.ReturnCode == DialogResult.OK )
        MessageBox.Show(test.Text);
}
  Permalink  
Comments
Abhishek Pant - 27 Jan '13 - 9:11
doesnt worked gives error at InputBoxResult and inputbox. so requires to generate the class.
Marcus Kramer - 2 Feb '13 - 11:03
Plagiarized from the article link posted by Abhishek Pant in Solution 2.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 243
1 Rohan Leuva 220
2 Sergey Alexandrovich Kryukov 208
3 Abhinav S 168
4 Mahesh Bailwal 165
0 Sergey Alexandrovich Kryukov 8,494
1 OriginalGriff 6,799
2 CPallini 3,603
3 Rohan Leuva 2,923
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid