By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,190 Members | 2,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,190 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

May 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
post some snippet code
Patrick

<aa*******@yahoo.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
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

May 20 '06 #2

P: n/a
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

May 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.