Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:21pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

for windows forms-
InputBox in C#[^]
for webforms-
modal popup using jquery[^]
or use ajax modal popup extender
  Permalink  
Comments
Abhishek Pant at 27-Jan-13 9:04am
   
Downvoter must see the link then only try to downvote.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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 at 27-Jan-13 9:11am
   
doesnt worked gives error at InputBoxResult and inputbox. so requires to generate the class.
Marcus Kramer at 2-Feb-13 11:03am
   
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
0 OriginalGriff 255
1 Sergey Alexandrovich Kryukov 104
2 Richard MacCutchan 100
3 kbrandwijk 75
4 Vinay Mistry 70
0 Sergey Alexandrovich Kryukov 9,040
1 OriginalGriff 8,121
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100