I list the code below, but the line that has the error is:
txtCompanyName.Enabled = false;
The error is:
Object reference not set to an instance of an object.
Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
protected System.Web.UI.UserControl Companies;
protected System.Web.UI.WebControls.TextBox txtCompanyName;
protected System.Web.UI.WebControls.TextBox txtUniqueCode;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
txtCompanyName.Enabled = false;
txtUniqueCode.Enabled = false;
}
----
--
Companies.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 Companies : System.Web.UI.UserControl
{
}
----
--
Companies.ascx
<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true"
CodeFile="Companies.ascx.cs" Inherits="Companies" %>
<table style="width: 348px">
<caption style="color: #ffffff; background-color: #6666cc;
font-weight: bold; font-family: Arial;" align="center">
New Client Information</caption>
<tr>
<td style="width: 544px; font-family: Arial; height: 6px;
background-color: buttonface;" bordercolor="#ffffff"
bgcolor="buttonface">
<asp:Label ID="lblCompanyName" runat="server" Text="Company
Name:" Width="150px" Font-Names="Arial"></asp:Label></td>
<td style="width: 318px; height: 6px;" bordercolor="#ffffff"
bgcolor="buttonface">
<asp:TextBox ID="txtCompanyName" runat="server"
CausesValidation="True" Width="220px"></asp:TextBox></td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="Must Enter Company Name"
ControlToValidate="txtCompanyName"></asp:RequiredFieldValidator><td
style="height: 6px; width: 3px;" bordercolor="#ffffff">
<tr>
<td style="width: 544px; font-family: Arial; background-color:
buttonface; height: 6px;" bgcolor="buttonface">
<asp:Label ID="lblUniqueCode" runat="server" Text="Unique
Client Code:" Width="150px" Font-Names="Arial"></asp:Label></td>
<td style="width: 318px" bgcolor="buttonface">
<asp:TextBox ID="txtUniqueCode" runat="server" Wrap="False"
Width="220px"></asp:TextBox></td>
</tr>
</table>
Does it matter that the textboxes are only defined in the html code?
What do I need?
Thanks,
ripripA quick glance reveals that your text boxes are part of a user control and
you are attempting the examing them in another page. The control is only
available in the user control form.
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
----
<aarepasky@.yahoo.com> wrote in message
news:1148340693.800290.207700@.j33g2000cwa.googlegroups.com...
>I list the code below, but the line that has the error is:
> txtCompanyName.Enabled = false;
> The error is:
> Object reference not set to an instance of an object.
> Default.aspx.cs
> using System;
> using System.Data;
> using System.Configuration;
> 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 _Default : System.Web.UI.Page
> {
> protected System.Web.UI.UserControl Companies;
> protected System.Web.UI.WebControls.TextBox txtCompanyName;
> protected System.Web.UI.WebControls.TextBox txtUniqueCode;
> protected void Page_Load(object sender, EventArgs e)
> {
> }
> protected void Button1_Click(object sender, EventArgs e)
> {
> txtCompanyName.Enabled = false;
> txtUniqueCode.Enabled = false;
> }
> ----
--
> Companies.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 Companies : System.Web.UI.UserControl
> {
> }
> ----
--
> Companies.ascx
> <%@. Control Language="C#" AutoEventWireup="true"
> CodeFile="Companies.ascx.cs" Inherits="Companies" %>
> <table style="width: 348px">
> <caption style="color: #ffffff; background-color: #6666cc;
> font-weight: bold; font-family: Arial;" align="center">
> New Client Information</caption>
> <tr>
> <td style="width: 544px; font-family: Arial; height: 6px;
> background-color: buttonface;" bordercolor="#ffffff"
> bgcolor="buttonface">
> <asp:Label ID="lblCompanyName" runat="server" Text="Company
> Name:" Width="150px" Font-Names="Arial"></asp:Label></td>
> <td style="width: 318px; height: 6px;" bordercolor="#ffffff"
> bgcolor="buttonface">
> <asp:TextBox ID="txtCompanyName" runat="server"
> CausesValidation="True" Width="220px"></asp:TextBox></td>
> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
> runat="server" ErrorMessage="Must Enter Company Name"
> ControlToValidate="txtCompanyName"></asp:RequiredFieldValidator><td
> style="height: 6px; width: 3px;" bordercolor="#ffffff">
> <tr>
> <td style="width: 544px; font-family: Arial; background-color:
> buttonface; height: 6px;" bgcolor="buttonface">
> <asp:Label ID="lblUniqueCode" runat="server" Text="Unique
> Client Code:" Width="150px" Font-Names="Arial"></asp:Label></td>
> <td style="width: 318px" bgcolor="buttonface">
> <asp:TextBox ID="txtUniqueCode" runat="server" Wrap="False"
> Width="220px"></asp:TextBox></td>
> </tr>
> </table>
> Does it matter that the textboxes are only defined in the html code?
> What do I need?
> Thanks,
> riprip
>
0 comments:
Post a Comment