473,663 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
2 5604
post some snippet code
Patrick

<aa*******@yaho o.com> wrote in message
news:11******** **************@ j73g2000cwa.goo glegroups.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
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.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts ;
using System.Web.UI.H tmlControls;

public partial class _Default : System.Web.UI.P age
{
protected System.Web.UI.U serControl Companies;
protected System.Web.UI.W ebControls.Text Box txtCompanyName;
protected System.Web.UI.W ebControls.Text Box txtUniqueCode;

protected void Page_Load(objec t sender, EventArgs e)
{

}

protected void Button1_Click(o bject sender, EventArgs e)
{
txtCompanyName. Enabled = false;
txtUniqueCode.E nabled = false;
}

---------------------------------------------------------------------------------------
Companies.aspx. cs

using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;

public partial class Companies : System.Web.UI.U serControl
{

}

---------------------------------------------------------------------------------------
Companies.ascx

<%@ Control Language="C#" AutoEventWireup ="true"
CodeFile="Compa nies.ascx.cs" Inherits="Compa nies" %>
<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="#f fffff"
bgcolor="button face">
<asp:Label ID="lblCompanyN ame" runat="server" Text="Company
Name:" Width="150px" Font-Names="Arial"></asp:Label></td>
<td style="width: 318px; height: 6px;" bordercolor="#f fffff"
bgcolor="button face">
<asp:TextBox ID="txtCompanyN ame" runat="server"
CausesValidatio n="True" Width="220px"></asp:TextBox></td>
<asp:RequiredFi eldValidator ID="RequiredFie ldValidator1"
runat="server" ErrorMessage="M ust Enter Company Name"
ControlToValida te="txtCompanyN ame"></asp:RequiredFie ldValidator><td
style="height: 6px; width: 3px;" bordercolor="#f fffff">

<tr>
<td style="width: 544px; font-family: Arial; background-color:
buttonface; height: 6px;" align="right" bgcolor="button face">
<asp:Label ID="lblUniqueCo de" runat="server" Text="Unique
Client Code:" Width="150px" Font-Names="Arial"></asp:Label></td>
<td style="width: 318px" bgcolor="button face">
<asp:TextBox ID="txtUniqueCo de" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1753
by: bala | last post by:
hi there the senario - an A2k application is distributed as a mdb to various users. they are not packaged. rich textbox is being used in one form. requirement - in some of the user's machine (am not sure which version of windows they have) when the application is run, the application error's out due to the absense of rich textbox. what i am trying to do is find out whether rich textbox is present in the user machine and then load a...
0
2117
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox should be set to a, selectable, in-focus color. 2) Out-of-focus color, when the textbox loses focus the backcolor property of the textbox should be set to a, selectable, out-of-focus color.
2
18152
by: Robbie | last post by:
I have a Web Form with some tailored logos and artwork. The web form also has a user control that has typical registration info on it (Name, Company Name, etc.) One of the fields, a TextBox, is a PromoCode which is a field required for each company which registers. I want to programatically set the value of this PromoCode in the host web-form's Page_Load method, but I can't seem to do it. My user control is "RegisterInfo.ascx" (On the...
9
2118
by: nail | last post by:
Hi. So I have a default.aspx page and 3 WebUserControls In the WebUserControl1, I have on TexBox, and in the default.aspx page I have a Button control. On the click event of the default.aspx page I need to change the TextBox.Text value, but not user the FindControl Method because I think this methos very slow. So, I want this, but not with findcontrol:
1
1951
by: Kum | last post by:
Hi, I need help in asp.net dynamic textbox controls validation. I am creating textbox controls dynamically on a asp.net webpage. Now after creating the textboxes on the page I want to validate these text boxes when the user submits or posts back to the server. My intention was to create a textboxvalidator function which takes the control name as argument and returns an true if
4
2686
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to be populated in the textbox. I use the user control on a index.aspx page. In order to achieve this I have a selected intexchange event on the calendar control. I pass the textbox id using the querystring when the button is clicked and then...
2
5882
by: Sridhar | last post by:
Hi, I have a user control which has a textbox control and a button. I have created a property to get and set the text box value. In the Page_Load method of the Page that contains the user control, I am setting the textbox value that is inside the user control. When I click the button that is inside the user control and try to access the textbox value it is getting empty string instead of the value set in the Page_Load. I have tried...
1
3214
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' & 'Cancel'). Till this point, no problem. Initially, the TextBox is empty. The Button has a property named 'ConfirmMessage' so that the developer using this custom control can modify the question in the confirm dialog. If the user clicks 'OK', I want the...
6
2236
by: =?Utf-8?B?SFJzb2Z0IEluZm9ybcOhdGljYQ==?= | last post by:
I Have a page (clientes.aspx), inside a masterpage I have some textbox, and when the user clicks the button 'Cancel', I need to empty all controls. I tried this, with runtine error: For Each txtControl As TextBox In Me.Controls txtControl.Text = "" Next error message in runtime: can't convert as object of type 'ASP.masterpage_master' in type
3
4851
by: crjunk | last post by:
Hi Everyone, I have a web form that I would like to enhance. What I'd like to do is this: A user adds/edits the text in a textbox. I want the adjoining label to change color. Example: User edits text in txtCaseNumber. The cursor leaves txtCaseNumber. Code executes and turns lblCaseNumber text from black to red.
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.