Link to home
Start Free TrialLog in
Avatar of 5281
5281

asked on

.net set focus on control without submitting form

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.
Avatar of Barry62
Barry62
Flag of United States of America image

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
Avatar of 5281
5281

ASKER

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.
Sorry, try changing the sub to Public.

You said it was vb.net
Avatar of 5281

ASKER

It is still same errors after change sub to Public.
ASKER CERTIFIED SOLUTION
Avatar of Barry62
Barry62
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 5281

ASKER

That's what I thought too.  I got it now.  Thank you.