Solved

Help with placing focus on button in message box

Posted on 2012-03-20
5
197 Views
Last Modified: 2012-03-21
Hello,

I am using the code below  for users to decide Yes/No, is there a way to place the focus on No automatically and they would only need to press Enter or Click on it? Below is the code I am using.

Dim anadd As String
                    anadd = MsgBox("Are you sure you want to Add this record?", MsgBoxStyle.YesNo, "Warning before Attempting Adding record")
                    If anadd = MsgBoxResult.Yes Then
                     code is executed.....

I am using ASP.NET

Thanks,

Victor
0
Comment
Question by:vcharles
  • 3
5 Comments
 
LVL 2

Expert Comment

by:Sirjacksinurbox
ID: 37743148
I believe you are looking for MsgBoxDefaultButton. Then you have to play around with which button it might be. Should be button 2 though.

Here is an example:

MsgBox.Show(messageString, "Do you want to quit?", MsgBoxButtons.YesNo, MsgBoxIcon.Question, MsgBoxDefaultButton.Button2) 

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37743742
You will have to use Messagebox.Show as I believe msgbox does not accept this parameter
0
 
LVL 2

Accepted Solution

by:
Sirjacksinurbox earned 500 total points
ID: 37743837
Oops, CodeCruiser is right. I was getting the two mixed up. The link below should explain every clearly.

MessageBoxDefaultButton Enumeration

In my rush to answer the question,  I forgot that MsgBox and Messagebox.Show() are essentially the same thing, except that Messagebox.Show() allows for far more customization though.

Thank you for clarifying that CodeCruiser.
0
 

Author Closing Comment

by:vcharles
ID: 37750370
Thank You!
0
 
LVL 2

Expert Comment

by:Sirjacksinurbox
ID: 37750507
My pleasure. Thanks for asking!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now