473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.....
Jul 28 '08 #1
5 1128
Curtis Rutland
3,256 Expert 2GB
You need to clarify your question. Is this a website or a desktop application? And I'm really not sure what you are asking.
Jul 28 '08 #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.

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...
Jul 28 '08 #3
Curtis Rutland
3,256 Expert 2GB
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."
Jul 28 '08 #4
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
Jul 28 '08 #5
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(object sender, EventArgs e)
{
Stream myStream = null;
DialogResult dlgResult = MessageBox.Show("Do you want to continue?", "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dlgResult == DialogResult.Yes)
{
if (openFileDialog1.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.
Jul 29 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sk2000 | last post by:
Hello All, I'm creating a web form with user controls in different HTML table cells (User Controls are place in the table cells at design time ). For some reason none of the Button type...
4
by: simon | last post by:
If I have <form runat=server> then I can't submit to other page. If I remove runat=server then my controls on that page doesn't work? So I should redirect to other page from codeBehind but how...
1
by: NH | last post by:
I would like to display a little pop-up message, or something when the user of Web Page submits data to be populated on DataGrid and not to remove all the other controls from the web page. ...
4
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing...
2
by: guoqi zheng | last post by:
Dear sir, I have two button controls in a repeater, when clicked, it fire an event R1_ItemCommand, but how can I know which button controls user click?? there are two there??? Sub...
4
by: antonyliu2002 | last post by:
I am new to the .NET framework. I know this has been discussed many times in this group. I also read extensively here, however, I am in bad luck: none of the sample code provided in this forum...
3
by: Aahz | last post by:
I have big asp.net , c# project with many buttons and image buttons that suddenly stop firing, when you click on button form -nothins happen. What strange that in Firefox they are still work...
3
by: velu | last post by:
How to Pass Panel visibility property to other page? I have a scenario here. I have created a user control that has a button and panel visible set to false. When I click the button if the...
4
by: ~john | last post by:
If I have a label on the Master Page that I would like to change its text with a button on one of the content pages, Default.aspx... It's giving me an error saying "Label1" is not found. Can you...
6
by: Marc | last post by:
Hi, I am using the below code which simply allows a single button control to be dragged and dropped anywhere around a form. My problem is that want to move about 100 buttons on the form. Is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.