Finally I found out how the error "'null' is null or not an object" happens. It happens on using Ajax and Validators together. If I take out the Validators, the error goes away. BUT I NEED THOSE VALIDATORS!! hehehe.
Somebody has the trick to get it working (Ajax and Validators) ?
I'm posting the code here so you can see the error by your own way. Notice when you remove the validators the application shows no error.
How use the code: type a text in the textbox. Click the "Click me" button. Now, try click the "Back" button and look at the error at status bar.
How take the error out: delete the RequiredFieldValidator and the error is gone.
What's weird is this is also causing me a problem, but not on my developent machine or my productstion server - but on the website clients hosting machine I get this error.
All I can say is Thank You! I knew it was due to the redering process and showing / hiding controls, but was completely stumped. Setting the validators to EnableClientScript = "false" worked!
ronchese
Member
16 Points
13 Posts
Error 'null' is null or not an object. It happens when I use Validators
Feb 02, 2007 06:39 PM|LINK
Hello All.
Finally I found out how the error "'null' is null or not an object" happens. It happens on using Ajax and Validators together. If I take out the Validators, the error goes away. BUT I NEED THOSE VALIDATORS!! hehehe.
Somebody has the trick to get it working (Ajax and Validators) ?
I'm posting the code here so you can see the error by your own way. Notice when you remove the validators the application shows no error.
How use the code: type a text in the textbox. Click the "Click me" button. Now, try click the "Back" button and look at the error at status bar.
How take the error out: delete the RequiredFieldValidator and the error is gone.
***************************************************************************************
DEFAULT2.ASPX:
***************************************************************************************
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><%
@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Untitled Page</title></
head><
body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <br />Page GUID:
<asp:Label ID="lblPageGUID" runat="server" Text="Label"></asp:Label> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="400px"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="Please type a text"></asp:RequiredFieldValidator><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click me" /></asp:Panel> <asp:Panel ID="Panel2" runat="server" Height="50px" Visible="False" Width="400px"> <asp:Label ID="Label1" runat="server" Text="Your text"></asp:Label> <br /> <asp:Button ID="Button2" runat="server" Text="Back" OnClick="Button2_Click" /></asp:Panel> </ContentTemplate> </asp:UpdatePanel> <br /> <br />
</div> </form></
body></
html>***************************************************************************************
DEFAULT2.ASPX.CS:
***************************************************************************************
using
System;using
System.Data;using
System.Configuration;using
System.Collections;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;public
partial class Default2 : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
lblPageGUID.Text =
Guid.NewGuid().ToString();}
protected void Button1_Click(object sender, EventArgs e){
Panel1.Visible =
false;Panel2.Visible =
true;Label1.Text =
"Your text is: " + TextBox1.Text;}
protected void Button2_Click(object sender, EventArgs e){
Panel1.Visible =
true;Panel2.Visible =
false;}
}
alivemedia
Member
43 Points
54 Posts
Re: Error 'null' is null or not an object. It happens when I use Validators
Feb 13, 2007 03:21 PM|LINK
ronchese
Member
16 Points
13 Posts
Re: Error 'null' is null or not an object. It happens when I use Validators
Aug 29, 2007 05:21 PM|LINK
Well, I solved the problem marking EnableClientScript = False to all validators. Once the processing is not made in client page anymore, it works.
mrbaseball2u...
Member
9 Points
3 Posts
Re: Error 'null' is null or not an object. It happens when I use Validators
Dec 10, 2007 06:57 PM|LINK
All I can say is Thank You! I knew it was due to the redering process and showing / hiding controls, but was completely stumped. Setting the validators to EnableClientScript = "false" worked!
Sincerely,
Brad Bradley
Javascript & Ajax & IE7 & Postback