User Control Strange Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi Raed Sawalha,

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

Raymond
 
Great! it worked well....but what is the reason that I need to declare it as
protected?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top