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

controls on a base page not available?

If I inherit from a custom base page, it seems that the controls on the base page are unavailable.

e.g.

public class basePage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.HyperLink HyperLink1;

private void Page_Load(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("HyperLink1 is null = " + String.Format("{0}", HyperLink1 == null));
}
...
public class WebForm1 : basePage
{
protected System.Web.UI.WebControls.TextBox TextBox1;

private void Page_Load(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("TextBox1 is null = " + String.Format("{0}", TextBox1 == null));
}
...

This results in the following output:

HyperLink1 is null = True
TextBox1 is null = False

Why is the base page's HyperLink control not available?
Nov 18 '05 #1
3 1233
you need code to create the control. either in the code behind, or on the
aspx page source (which will generate the code).

-- bruce (sqlwork.com)

"Peter Young" <yo*****@comcast.no.net.spam.please> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
If I inherit from a custom base page, it seems that the controls on the base page are unavailable.
e.g.

public class basePage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.HyperLink HyperLink1;

private void Page_Load(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("HyperLink1 is null = " + String.Format("{0}", HyperLink1 == null)); }
...
public class WebForm1 : basePage
{
protected System.Web.UI.WebControls.TextBox TextBox1;

private void Page_Load(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("TextBox1 is null = " + String.Format("{0}", TextBox1 == null)); }
...

This results in the following output:

HyperLink1 is null = True
TextBox1 is null = False

Why is the base page's HyperLink control not available?

Nov 18 '05 #2
"bruce barker" <no***********@safeco.com> wrote in message news:uB*************@tk2msftngp13.phx.gbl...
you need code to create the control. either in the code behind, or on the
aspx page source (which will generate the code).


How do you mean? The control is already sited on the base page.
Nov 18 '05 #3
the code like:

HyperLink1 = new System.Web.UI.WebControls.HyperLink(); // create
control

of course you will need to add it to the pages control collection to be
rendered.
-- bruce (sqlwork.com)

"Peter Young" <yo*****@comcast.no.net.spam.please> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
"bruce barker" <no***********@safeco.com> wrote in message

news:uB*************@tk2msftngp13.phx.gbl...
you need code to create the control. either in the code behind, or on the aspx page source (which will generate the code).


How do you mean? The control is already sited on the base page.

Nov 18 '05 #4

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

Similar topics

3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
2
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the...
11
by: Frank Esser | last post by:
Hi, I created an ASP.NET page (test.aspx) with some web controls in GridLayout (Design time). When I look at the collection page.controls by foreach (Control ctrl in Page.Controls) { ....
8
by: novus | last post by:
Hi, In ASP.net 2.0 I make a control which add the same controls dynamically. In the oninit event I add the controls to the controls collection. After that the loadviewstate event fills in the...
9
by: Alan Silver | last post by:
Hello, I have a user control which I am trying to load dynamically, but am running into problems. I think the problem is because I have two .ascx files that refer to the same .ascx.cs file. A...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
12
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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,...

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.