After completing the first "Try it out" on page 296, I wanted to try something different. I added some code in the code behind file Controls/ContactForm.ascx.
vb for the button_click sub for the Send button. The code is supposed to display the ErrorMessage from the RequiredFieldValidator1 control in a label that I added, if the text box for the name is empty. To debug the code, I put a breakpoint on the button_click sub for the Send button, but it only steps through the code when I put and name in the box and click Send. It will not step throught the sub if the text box is empty and I click send. I'm I forgetting something from a previous lesson?
Here's my code:
Code:
Partial Class Controls_ContactForm
Inherits System.Web.UI.UserControl
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
If txtName.Text = String.Empty Then
lblForMessage.Text = RequiredFieldValidator1.ErrorMessage.ToString
End If
End Sub
End Class