Solved

.net set focus on control without submitting form

Posted on 2013-10-29
6
387 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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

728 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