Home All Groups Group Topic Archive Search About

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

Author
19 May 2006 2:41 AM
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

Author
20 May 2006 1:38 PM
Patrick.O.Ige
post some snippet code
Patrick

<aarepa***@yahoo.com> wrote in message
Show quoteHide quote
news:1148006508.970953.251270@j73g2000cwa.googlegroups.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
>
Are all your drivers up to date? click for free checkup

Author
21 May 2006 9:44 PM
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

Bookmark and Share