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

page to control in 2.0

This is an ASP.NET 2.0 question.

In 1.0, common techniques for communicating between a page and the
controls on it
depended on being able to declare variables of the page and control
types.
For example, if I had a page called MyPage.aspx, then I could declare a
variable
of type MyPage in my user control code. Typically I would have a
namespace with the same name as my project.

I don't know how to do this in 2.0. It seems to have something to do
with the page and user control classes being partial classes -- I can
declare variables
of any 'normal' classes in the project.

No doubt there's a simple solution.

Nov 19 '05 #1
1 1188
In 1.x the code-behind class for the control and the code-behind class
for the Page were visible to each other because both classes compiled
to the same assembly.

In 2.0, user control and Page types are not visible to each other by
default, unless you use an @ Reference directive (or an @ Register
directive for a control).

Here are a couple posts describing different scenarios in this area:
http://odetocode.com/Blogs/scott/arc...8/01/2030.aspx
http://odetocode.com/Blogs/scott/arc...6/30/1889.aspx

The problem you may run into is a circular reference if both the page
and control want to reference each other. If this is a case I'd define
an interface for your page in App_Code or another class library that
the Page derived class implements. The control can then talk to the
page through the interface.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 26 Sep 2005 12:48:12 -0700, jh*****@yahoo.com wrote:
This is an ASP.NET 2.0 question.

In 1.0, common techniques for communicating between a page and the
controls on it
depended on being able to declare variables of the page and control
types.
For example, if I had a page called MyPage.aspx, then I could declare a
variable
of type MyPage in my user control code. Typically I would have a
namespace with the same name as my project.

I don't know how to do this in 2.0. It seems to have something to do
with the page and user control classes being partial classes -- I can
declare variables
of any 'normal' classes in the project.

No doubt there's a simple solution.


Nov 19 '05 #2

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

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
5
by: Nathan Sokalski | last post by:
When I view my index.aspx page any time after the first time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize)...
4
by: TS | last post by:
When i try to access the page class or parent properties inside a server control that is nested in another server control, they are null. I don't even call CreateChildControls for the parent...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
5
by: Fernando Chilvarguer | last post by:
I'm sure this has come up before but I could not find any post on it. How can I read a variable or property that has been set on a ASPX page from inside a ASCX control. ASPX code: public...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
1
by: Jordan S. | last post by:
I'm just wondering if this would work. Please note that I'm not asking *how* to raise events. I'm clear on that. What I'm not clear on is the sequence in which events are raised by custom controls...
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.