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

Address Content Page Controls from Master

There is a lot of good material related to using Master Pages for formatting
controls and putting common design elements on multiple pages.

I have VB.NET code that is common to all of my pages for doing things like
rendering controls, making database connections, instantiating custom
classes, etc...

I am trying to figure out how to put code in the Master Page that will
address controls on the content pages which use that master - say for example
to set the text and tooltip of a button or label.

Is this possible? If so, how?

I tried defining a BasePage class and inheriting from that, but am having
trouble with the declarations for the events in the inheriting page.

Thanks!

Nov 29 '07 #1
5 1544
this is probably a poor design. the master page is just a control on the
actual page.

a better approach is your original approach of a base page. any problems
coding for events you had with a basepage you will have with a master.

you should spend the time to understand delegates, events and overrides
to overcome your original coding errors.

-- bruce (sqlwork.com)
Rbrt wrote:
There is a lot of good material related to using Master Pages for formatting
controls and putting common design elements on multiple pages.

I have VB.NET code that is common to all of my pages for doing things like
rendering controls, making database connections, instantiating custom
classes, etc...

I am trying to figure out how to put code in the Master Page that will
address controls on the content pages which use that master - say for example
to set the text and tooltip of a button or label.

Is this possible? If so, how?

I tried defining a BasePage class and inheriting from that, but am having
trouble with the declarations for the events in the inheriting page.

Thanks!
Nov 29 '07 #2
I wholeheartedly agree with Bruce, the base page is definitely the way to
go, but if you're looking for a quick fix FindControl will do it.

Mind you, there are caveats, big ones, but it'll get the job (poorly) done.

--
Regards,

Bryan Porter
http://www.bryanporter.com/

"What A Horrible Night To Have A Curse!" - S. Belmont
"bruce barker" <no****@nospam.comwrote in message
news:us**************@TK2MSFTNGP03.phx.gbl...
this is probably a poor design. the master page is just a control on the
actual page.

a better approach is your original approach of a base page. any problems
coding for events you had with a basepage you will have with a master.

you should spend the time to understand delegates, events and overrides to
overcome your original coding errors.

-- bruce (sqlwork.com)
Rbrt wrote:
>There is a lot of good material related to using Master Pages for
formatting controls and putting common design elements on multiple pages.

I have VB.NET code that is common to all of my pages for doing things
like rendering controls, making database connections, instantiating
custom classes, etc...

I am trying to figure out how to put code in the Master Page that will
address controls on the content pages which use that master - say for
example to set the text and tooltip of a button or label.

Is this possible? If so, how?

I tried defining a BasePage class and inheriting from that, but am having
trouble with the declarations for the events in the inheriting page.

Thanks!
Nov 29 '07 #3
Yeah I am trying to do that but for some reason I keep getting a blue
squiggly that talks about using WithEvents when I put a Handles statement in
an Event Handler of the child (inheriting) page.

This used to be simple in 1.1 !

"bruce barker" wrote:
this is probably a poor design. the master page is just a control on the
actual page.

a better approach is your original approach of a base page. any problems
coding for events you had with a basepage you will have with a master.

you should spend the time to understand delegates, events and overrides
to overcome your original coding errors.

-- bruce (sqlwork.com)
Rbrt wrote:
There is a lot of good material related to using Master Pages for formatting
controls and putting common design elements on multiple pages.

I have VB.NET code that is common to all of my pages for doing things like
rendering controls, making database connections, instantiating custom
classes, etc...

I am trying to figure out how to put code in the Master Page that will
address controls on the content pages which use that master - say for example
to set the text and tooltip of a button or label.

Is this possible? If so, how?

I tried defining a BasePage class and inheriting from that, but am having
trouble with the declarations for the events in the inheriting page.

Thanks!
Nov 29 '07 #4
Gotcha.

Our FormView is far too customized to be useful to anyone else. We've got
all kinds of crap in there. But the part you might be interested in is a
very simple recursive routine that binds controls to our custom business
object. Here it is:

protected virtual void GenerateFieldBindings(Control containerControl)
{
// Loop through all controls and attempt to wire-up fields by matching
// the control ID to the field name.
foreach (Control c in containerControl.Controls)
{
if (c.ID != null)
foreach (IField f in BoundObject.Fields)
if (c.ID.ToUpper() == f.FieldName.ToUpper())
AddFieldBinding(c, f);

GenerateFieldBindings(c);
}
}
So, if you replace "BoundObject.Fields" with
"YourCollectionOfObjectsObtainedFromYourDB" you're pretty much set. Just
pass in a reference to your "page" to get the ball rolling (e.g. in the
Page_Load just call GenerateFieldBindings(this)).

"Rbrt" <Rb**@discussions.microsoft.comwrote in message
news:E6**********************************@microsof t.com...
>I am building an application that is multilingual. The text elements are
stored in a database table and when the page loads, I get all the text
stuff
for the controls on that page (text, tooltip, messages for validators,
etc...) in the current user's language and then I go through each control
and
set the text property, tooltip property, what have you. To do this I have
created a special interface class that does the heavy lifting - reading
the
database, getting the properties, etc...

I'd be interested to hear more about that custom FormView if you've the
time.
Nov 29 '07 #5
Thank you!

"Scott Roberts" wrote:
Gotcha.

Our FormView is far too customized to be useful to anyone else. We've got
all kinds of crap in there. But the part you might be interested in is a
very simple recursive routine that binds controls to our custom business
object. Here it is:

protected virtual void GenerateFieldBindings(Control containerControl)
{
// Loop through all controls and attempt to wire-up fields by matching
// the control ID to the field name.
foreach (Control c in containerControl.Controls)
{
if (c.ID != null)
foreach (IField f in BoundObject.Fields)
if (c.ID.ToUpper() == f.FieldName.ToUpper())
AddFieldBinding(c, f);

GenerateFieldBindings(c);
}
}
So, if you replace "BoundObject.Fields" with
"YourCollectionOfObjectsObtainedFromYourDB" you're pretty much set. Just
pass in a reference to your "page" to get the ball rolling (e.g. in the
Page_Load just call GenerateFieldBindings(this)).

"Rbrt" <Rb**@discussions.microsoft.comwrote in message
news:E6**********************************@microsof t.com...
I am building an application that is multilingual. The text elements are
stored in a database table and when the page loads, I get all the text
stuff
for the controls on that page (text, tooltip, messages for validators,
etc...) in the current user's language and then I go through each control
and
set the text property, tooltip property, what have you. To do this I have
created a special interface class that does the heavy lifting - reading
the
database, getting the properties, etc...

I'd be interested to hear more about that custom FormView if you've the
time.

Nov 29 '07 #6

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

Similar topics

0
by: Abraham Andres Luna | last post by:
i have a master page: <%@ Master Language="C#" %> <html> <head> <title>CRM - RDK Truck Sales & Service</title> </head> <body> <form runat="server"> <asp:contentplaceholder...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
0
by: Kevin Frey | last post by:
We have a data-centric application where all of the "layout" for each data centric page is to be codified (ie. it is expressed in C# code rather than being expressed declaratively). This...
2
by: Zetatec2 | last post by:
I have a site I am making. It contains one master page that has two ASP label controls and about sixteen ASP button controls on it. Then I have sixteen content or slave pages. The user clicks on...
1
by: | last post by:
Hey all! I'm new to 2.0. I use user controls, and since 99% of browsers have css now, I use absolute positioning to place my user controls.(Top banners, menus on the left side etc). In my case,...
3
by: MikeB | last post by:
Hello, I have a content page that is from a Master page which has 2 content panes. How do I add my forms to the content page? Each pane needs a form but you can not have multiple form tags nor...
2
by: John | last post by:
Hi, I'm having trouble with nested master pages (and creating the same behaviour as Scott Guthrie's blog post...
1
by: Michael Nemtsev [MVP] | last post by:
Hello gerry, Everything ok with your code - it works fine and I see controls in designer - i just rebuld project and everything okey-dokey As I understand u are using VS 2008. Try to install the...
1
by: Sinan Alkan | last post by:
In a master page --content page system, is it possible to change the "description" and "keywords" meta tags of the master page from content page ? I am trying as follows, from content page.... ...
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.