Textbox in User Control error -does not exist in current context

A

aarepasky

I am using ASP Web 2005 express and I have a textbox in a user control.
Now when I try to use it in another user control, I get the error that
it "does not exist in current context. These 2 user controls are each
in a panel on the page.

riprip
 
A

aarepasky

Here is some code. I have made changes and now I get the error:

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;" align="right" 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;" align="right" 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?

Thanks,
riprip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top