473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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 5570
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
0
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...
2
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...
9
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...
1
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...
4
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...
2
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...
1
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' &...
6
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...
3
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.