Solved

.net set focus on control without submitting form

Posted on 2013-10-29
6
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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