Solved

.net set focus on control without submitting form

Posted on 2013-10-29
6
381 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain "Multi-Tenant Services" 5 62
Server Error 11 47
Displaying a web form as a modal popup dialog box. 4 19
VS.net 2010 11 18
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

18 Experts available now in Live!

Get 1:1 Help Now