473,394 Members | 1,738 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,394 software developers and data experts.

User Control Strange Problem

I created a very simple user control which contains lable and drag the
control to page

<%@ Page language="c#" Codebehind="Validate.aspx.cs" AutoEventWireup="false"
Inherits="Learning.Validate" %>
<%@ Register TagPrefix="uc1" TagName="GroupFilesManager"
Src="GroupFilesManager.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Validate</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:GroupFilesManager id="oGroupFilesManager"
runat="server"></uc1:GroupFilesManager></form>
</body>
</HTML>

in cs file i define the control object as GroupFileManager oGroupFilesManager;
but when try to use a function in
oGroupFilesManager it null??? why
Nov 19 '05 #1
3 1073
Hi Raed Sawalha,

Try to declare it as protected member:
protected GroupFileManager oGroupFilesManager;

Raymond

"Raed Sawalha" wrote:
I created a very simple user control which contains lable and drag the
control to page

<%@ Page language="c#" Codebehind="Validate.aspx.cs" AutoEventWireup="false"
Inherits="Learning.Validate" %>
<%@ Register TagPrefix="uc1" TagName="GroupFilesManager"
Src="GroupFilesManager.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Validate</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:GroupFilesManager id="oGroupFilesManager"
runat="server"></uc1:GroupFilesManager></form>
</body>
</HTML>

in cs file i define the control object as GroupFileManager oGroupFilesManager;
but when try to use a function in
oGroupFilesManager it null??? why

Nov 19 '05 #2
Great! it worked well....but what is the reason that I need to declare it as
protected?

"Raymond Yuen" wrote:
Hi Raed Sawalha,

Try to declare it as protected member:
protected GroupFileManager oGroupFilesManager;

Raymond

"Raed Sawalha" wrote:
I created a very simple user control which contains lable and drag the
control to page

<%@ Page language="c#" Codebehind="Validate.aspx.cs" AutoEventWireup="false"
Inherits="Learning.Validate" %>
<%@ Register TagPrefix="uc1" TagName="GroupFilesManager"
Src="GroupFilesManager.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Validate</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:GroupFilesManager id="oGroupFilesManager"
runat="server"></uc1:GroupFilesManager></form>
</body>
</HTML>

in cs file i define the control object as GroupFileManager oGroupFilesManager;
but when try to use a function in
oGroupFilesManager it null??? why

Nov 19 '05 #3
If you declare it as "protected" member, then the ASP.NET runtime will "know"
that the control declared on your WebForm is inherited from the object
declared in its code-behind page. Otherwise, the object declared in the
code-behind will be an independent object.

Raymond

"Raed Sawalha" wrote:
Great! it worked well....but what is the reason that I need to declare it as
protected?

"Raymond Yuen" wrote:
Hi Raed Sawalha,

Try to declare it as protected member:
protected GroupFileManager oGroupFilesManager;

Raymond

"Raed Sawalha" wrote:
I created a very simple user control which contains lable and drag the
control to page

<%@ Page language="c#" Codebehind="Validate.aspx.cs" AutoEventWireup="false"
Inherits="Learning.Validate" %>
<%@ Register TagPrefix="uc1" TagName="GroupFilesManager"
Src="GroupFilesManager.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Validate</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:GroupFilesManager id="oGroupFilesManager"
runat="server"></uc1:GroupFilesManager></form>
</body>
</HTML>

in cs file i define the control object as GroupFileManager oGroupFilesManager;
but when try to use a function in
oGroupFilesManager it null??? why

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: BBM | last post by:
Hi, I have been developing with C# User Controls and occasionally have a problem where I "lose" a control from the design surface of the User Control. The controls that I am using to build my...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
0
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
4
by: Joseph Geretz | last post by:
Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the richness and elegance of the environment. However, richness and elegance should be dedicated toward making development easier for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.