How to get button controls on message box to navigate to other page.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AbhiramReddyMekha
    New Member
    • Jul 2008
    • 3

    How to get button controls on message box to navigate to other page.

    I have an application in which, I have to display a message box depending on a validation if yes, I have to stay in the same page otherwise a file dialogue box is to be displayed.
    can you please help me to get it.....
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You need to clarify your question. Is this a website or a desktop application? And I'm really not sure what you are asking.

    Comment

    • AbhiramReddyMekha
      New Member
      • Jul 2008
      • 3

      #3
      Originally posted by insertAlias
      You need to clarify your question. Is this a website or a desktop application? And I'm really not sure what you are asking.

      Actually it's a windows application with C# ,what I need is, to validate a text box and then depending on the result, I need to navigate to next page or same page with one button control and with other button control I need to open a file dialogue box..........
      Like when we write something in notepad and close it with out saving then a message box will be displayed with options like Yes, No, Cancel clicking on Yes we will get file dialogue box opened and clicking on No closes it......
      like that...

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        This is a fairly generic question...so it's hard to give you a concrete answer.

        Just use if statements, and based on the result, either display the file dialogue, or do whatever else you need to do. Perhaps you could use Panels, and make one visible/hidden when you validate your textbox and need to go to the other "page."

        BTW, what "page" are you talking about? Windows Forms apps don't have "pages."

        Comment

        • programmerboy
          New Member
          • Jul 2007
          • 84

          #5
          Well, as far as I understood your question what you can do is to define a dialogresult variable and then show your message and then assign the value of messagebox to that dialogresult variable. For example

          Dim DialogResult dr

          dr = MessageBox.Show (whatever buttons you want here)

          'When you get the value in dr variable then either use Select or IF statement

          Hope that helps

          Comment

          • AbhiramReddyMekha
            New Member
            • Jul 2008
            • 3

            #6
            Hi.....
            'Programmerboy' given me an idea and depending on that I tried to solve my issue and got it. I write the code like this and I got my issue solved.

            private void button1_Click(o bject sender, EventArgs e)
            {
            Stream myStream = null;
            DialogResult dlgResult = MessageBox.Show ("Do you want to continue?", "Continue?" , MessageBoxButto ns.YesNo, MessageBoxIcon. Question);
            if (dlgResult == DialogResult.Ye s)
            {
            if (openFileDialog 1.ShowDialog() == DialogResult.OK )
            {
            try
            {
            if ((myStream = openFileDialog1 .OpenFile()) != null)
            {
            using (myStream)
            {
            // Inserted code to read the stream here.
            }
            }
            }
            catch (Exception ex)
            {
            MessageBox.Show ("Error: Could not read file from disk. Original error: " + ex.Message);
            }
            }
            }
            else if (dlgResult == DialogResult.No )
            {
            // Showed the Form required.
            }

            }

            Thank you.
            Last edited by AbhiramReddyMekha; Jul 29 '08, 06:00 AM. Reason: correction

            Comment

            Working...