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

User Control and Parent

What is the code to read a field value of the Parent Page from an embedded
User Control?
I can use reflection to get it, but I thought there would be an easier way.
--
Joe Fallon

Nov 18 '05 #1
2 1074
A UserControl has a Parent property, which you can use to get a reference to
the parent. If you then cast this as the type of your parent class, you can
access any public members of that class.

....
ParentPage myParent = this.Parent as ParentPage;
if (myParent != null) {
myParent.SomeMethod();
}
....
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:et******************@TK2MSFTNGP12.phx.gbl...
What is the code to read a field value of the Parent Page from an embedded
User Control?
I can use reflection to get it, but I thought there would be an easier
way.
--
Joe Fallon


Nov 18 '05 #2
Thanks Chris, I will give it a shot.
--
Joe Fallon

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
A UserControl has a Parent property, which you can use to get a reference to the parent. If you then cast this as the type of your parent class, you can access any public members of that class.

...
ParentPage myParent = this.Parent as ParentPage;
if (myParent != null) {
myParent.SomeMethod();
}
...
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:et******************@TK2MSFTNGP12.phx.gbl...
What is the code to read a field value of the Parent Page from an embedded User Control?
I can use reflection to get it, but I thought there would be an easier
way.
--
Joe Fallon



Nov 18 '05 #3

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

Similar topics

0
by: Jack | last post by:
Hello everyone, I have an event the kicks off from way down inside a user control. It is 4-5 levels deep, i.e. me.parent.parent.parent.parent.parent is the main form. The event needs to be able...
1
by: Ian | last post by:
I have a parent MDI with a menu that calls all the children forms and that works fine. My issue is I created a user control that looks like a toolbar and it has various windows controls on it and...
3
by: David K. | last post by:
My question concerns C# Windows Forms user controls. I have created navigation user control. It gets the consumer application parent control's (a Form) CurrencyManager to its bindable property. In...
1
by: moondaddy | last post by:
I need to replace a user control on a page with a different user control. The challenge I'm faced with is that this call is being made from the user control being replaced. Normally I replace...
5
by: George Durzi | last post by:
I have a simple user control with a text box and a submit button. When the user enters some text into the textbox and clicks the submit button, a record is created in the database. I'm using...
5
by: Steve Richter | last post by:
In my user control I want to read the ViewState dictionary of the Parent control. But this sensible idea is not permitted by the compiler: Compiler Error Message: CS1540: Cannot access...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
6
by: Art | last post by:
Hi I'm new at this and need some help. I have a "solution" with 2 projects - the main project and a library. The library is simple, it contains a text box that will appear many times in the form...
1
by: David Lozzi | last post by:
Hello, I have a user control that saves data. When the data is saved, I need to call a function in the parent page from the user control to initiate something else. I know I can set it up so...
6
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload 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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...

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.