Solved

.net set focus on control without submitting form

Posted on 2013-10-29
6
380 Views
Last Modified: 2013-10-30
I want to promp user to input resolution before submit a form.  How can I set focus on the resolution textbox and without submitting form if the resolution textbox is empty.

The app is in vb.net, I think I need the code in vb.net.  Thanks.
0
Comment
Question by:5281
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:Barry62
ID: 39609648
Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
      if txtResolution.text = String.empty() Then
          MessageBox.Show("Please enter a resolution", "No Resolution Entered", MessageBoxButtons.OK, MessageBoxIcon.Error);
      Else
          <Process Form...>
      End If
End Sub
0
 

Author Comment

by:5281
ID: 39609713
when I moved your code in my Visual Studio, somehow, I have error under String.Empty() and MessageBox

String.Empty() - Error 100 Argument not specified for parameter 'index' of 'Public ReadOnly Default Property Chars(index As Integer) As Char'.      

MessageBox - Error      101 'MessageBox' is not declared. It may be inaccessible due to its protection level.      

What happened?  This is asp.net web application.
0
 
LVL 8

Expert Comment

by:Barry62
ID: 39609731
Sorry, try changing the sub to Public.

You said it was vb.net
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:5281
ID: 39609794
It is still same errors after change sub to Public.
0
 
LVL 8

Accepted Solution

by:
Barry62 earned 500 total points
ID: 39609809
String.Empty()

Since this is asp.net, not vb.net, you'll have to use javascript alert() instead of MessageBox
0
 

Author Comment

by:5281
ID: 39611382
That's what I thought too.  I got it now.  Thank you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

19 Experts available now in Live!

Get 1:1 Help Now