How to display the Pop Up message after clicking the button in VB.net

ctsenthil

Member
Joined
May 27, 2005
Messages
5
Programming Experience
Beginner
If the user press the button i want to diplay the pop up message to get what action wants to be performed whether he wants to print the content in EXCEL or in HTML.

Please help me out
 
Last edited:
Drop a button on on a form and give this a try

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim response As MsgBoxResult

response = MsgBox("Do you want to continue", MsgBoxStyle.YesNo, "Hey")
' message,style,title

If response = MsgBoxResult.Yes Then

MsgBox("Yes")

Else

MsgBox("No")

End If

End Sub

 
I'm afraid I don't really understand your question. Could you please rephrase
your question? Maybe terminology is a large part of the problem here ... Pop Up message with choices (EXCEL & HTML) within?!.

I don't think so that we think the same as MessageBox class cannot provide that functionality.

Maybe, for the purpose you'll have to make a new form that will be shown instead of messagebox ...

Feel free to ask if you need an additional assistence ... Cheers ;)
 
You can use a MessageBox class (I suggest using System.Windows.Forms.MessageBox instead of the older Microsoft.VisualBasic.Interaction.MsgBox Function).
You could include a message such as "Do you want to print the content in Excel format? Press No to print the content in HTML format" and include Yes, No, and Cancel buttons using System.Windows.Forms.MessageBoxButtons.YesNoCancel for the MessageBoxButtons parameter in the MessageBox.Show Function.
 
I would suggest using kulrom's method. While easier to program, it would be incorrect to use one of the standard button combinations on a MessageBox for the purpose you describe. It's not that hard to create a new form with a Label asking which printing method to use and two buttons with "Excel" and "HTML" on them. You can still give the buttons DialogResult values of "Yes" and "No" that you can use to determine how to proceed if you want to, although a more correct method would be to return DialogResult.OK and set a property to indicate which button was pressed. You could also include a Cancel button that returns DialogResult.Cancel.
 
Hi
Let me rephrase my Question
I had a button in the page,if the user clicks the button i want to display a pop up message saying "do you want to print the result in Excel or in HTML" and i want to get the confirmation from the user...

I tried dashleys method its throwing some error saying "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

Please help me to get it solved....


Thanks in Advance
 
The Environment.UserInteractive property is False only if your project is running as a Service or a Web application. Given that you say you your user is pressing a button I'm going to guess that yours is a Web app. Perhaps it would have been a good idea to mention this information in your original post. In fact, given that there is a whole section of this forum devoted to ASP, perhaps it would be a good idea to have posted there in the first place.
 
Back
Top