G
Gary Wardell
Hi,
I seem to have hit an odd problem.
I have the need to sometimes validate and sometimes not based on conditions
in a database.
However, the following page, which simulates the problem, works fine as a
stand alone page, but fails at the indicated line when used with a matter
page when clicking the NoVal button. It also fails when clicking the val
button, but only when with a master page.
I have no idea why or how to fix it.
Thanks for any help.
======================
<%@ Page Language="vb" AutoEventWireup="false"
MasterPageFile="~/CourtTech.Master" Codebehind="Test2.aspx.vb"
Inherits="TrueLog.Test2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Canvas" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="TBVal" ControlToValidate="TextBox1"
runat="server" ErrorMessage="*Required" /><br />
<asp:Button ID="Button1" runat="server" Text="Submit" /><br />
<asp:Button ID="NoVal" CausesValidation="false" runat="server"
Text="NoVal" /><br />
<asp:Button ID="Val" CausesValidation="false" runat="server"
Text="Val" />
</div>
</asp:Content>
=========================
Public Partial Class Test2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
End Sub
Private Sub NoVal_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles NoVal.Click
DirectCast(Me.FindControl("TBVal"), RequiredFieldValidator).Enabled =
False <--- System.NullReferenceException: Object reference not set to an
instance of an object.
End Sub
Private Sub Val_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Val.Click
DirectCast(Me.FindControl("TBVal"), RequiredFieldValidator).Enabled =
True
End Sub
End Class
I seem to have hit an odd problem.
I have the need to sometimes validate and sometimes not based on conditions
in a database.
However, the following page, which simulates the problem, works fine as a
stand alone page, but fails at the indicated line when used with a matter
page when clicking the NoVal button. It also fails when clicking the val
button, but only when with a master page.
I have no idea why or how to fix it.
Thanks for any help.
======================
<%@ Page Language="vb" AutoEventWireup="false"
MasterPageFile="~/CourtTech.Master" Codebehind="Test2.aspx.vb"
Inherits="TrueLog.Test2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Canvas" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="TBVal" ControlToValidate="TextBox1"
runat="server" ErrorMessage="*Required" /><br />
<asp:Button ID="Button1" runat="server" Text="Submit" /><br />
<asp:Button ID="NoVal" CausesValidation="false" runat="server"
Text="NoVal" /><br />
<asp:Button ID="Val" CausesValidation="false" runat="server"
Text="Val" />
</div>
</asp:Content>
=========================
Public Partial Class Test2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
End Sub
Private Sub NoVal_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles NoVal.Click
DirectCast(Me.FindControl("TBVal"), RequiredFieldValidator).Enabled =
False <--- System.NullReferenceException: Object reference not set to an
instance of an object.
End Sub
Private Sub Val_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Val.Click
DirectCast(Me.FindControl("TBVal"), RequiredFieldValidator).Enabled =
True
End Sub
End Class