Good day all. I have tried and failed to find an answer to a couple of errors I'm receiving with this small project I created. I have a master.masterpage and 3 other child pages (content). Each one has a different flavor of a form. All the others work fine. This particular content page is not giving me the results I want.
First, when I hit submit and there are no validation errors, I'd like the label populated with "Success!!". currently it does not display even though the fields are valid.
Second, I want to clear all textboxes with a clear button but receive the following error. "NullReferenceException was unhandled by user code."
Can someone explain where I need corrections with good learning points?
Here is my asp.net code and vb code.
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Page3.aspx.vb" Inherits="_Default" %>
Rental Car Application Sheet
<div id="button2">
<asp:Button ID="Button3" runat="server" Text="Clear" />
</div>
Partial Class _Default
Inherits System.Web.UI.Page
Dim form1 As Control
Protected Sub Button2_Click(sender As Object, e As EventArgs, ByVal f As System.EventArgs)
If Page.IsValid Then
Label11.Text = "Success!!"
End If
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
For Each Control In form1.Controls
If TypeOf Control Is TextBox Then
Control.Text = "" 'Clear all text
End If
Next Control
End Sub
End Class