I'm trying to iterate over all the form controls in my MasterPages content
page. Basically, I've got dropdowns, textboxes, etc that I want to format
in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormCo ntrols()
{
Color borderColor = ColorTranslator .FromHtml("#F5F 5F5");
Color fontColor = borderColor;
Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls)
{
if(control is TextBox || control is DropDownList || control is
Button)
{
WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id;
webControl.Bord erWidth = 1;
webControl.Bord erColor = borderColor;
webControl.Fore Color = fontColor;
webControl.Back Color = backgroundColor ;
}
}
}
</code>
Problem is, the 'this.Controls' collection only has a count of 1, but I have
over 45 textboxes alone! So obviously, I'm hitting the wrong collection,
but as I inspected this.Controls while debuggin I didn't understand how I
was looking at a MasterPage control as the only control in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really
appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this
way. I can get the dropdowns to work with my CSS, but the textboxes refuse.
Just for kicks, here is my CSS:
..input, select
{
background: #1E1E1E;
color: #F5F5F5;
border: 1px solid #F5F5F5;
}
Thanks for reading,
Steve 6 3266
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. ..
I'm trying to iterate over all the form controls in my MasterPages content
page. Basically, I've got dropdowns, textboxes, etc that I want to format
in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormCo ntrols()
{
Color borderColor = ColorTranslator .FromHtml("#F5F 5F5");
Color fontColor = borderColor;
Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls)
{
if(control is TextBox || control is DropDownList || control is
Button)
{
WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id;
webControl.Bord erWidth = 1;
webControl.Bord erColor = borderColor;
webControl.Fore Color = fontColor;
webControl.Back Color = backgroundColor ;
}
}
}
</code>
Problem is, the 'this.Controls' collection only has a count of 1, but I
have over 45 textboxes alone! So obviously, I'm hitting the wrong
collection, but as I inspected this.Controls while debuggin I didn't
understand how I was looking at a MasterPage control as the only control
in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really
appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this
way. I can get the dropdowns to work with my CSS, but the textboxes
refuse. Just for kicks, here is my CSS:
.input, select
{
background: #1E1E1E;
color: #F5F5F5;
border: 1px solid #F5F5F5;
}
Thanks for reading,
Steve
Hi Ken,
My problem is that in my content page, 'this.Controls' is the master page
control.
So I'm confused given a master control, how am I expected to get to a
content pages' controls? This seems especially odd considering I'm in the
Page_Load event of THE content page.
Maybe I'm still missing something?
Thanks for the reply, I appreciate it!
"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message
news:OC******** *****@TK2MSFTNG P05.phx.gbl...
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of
Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. ..
>I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load()
I've added this code to my Page_Load() event <code> private void ConfigureFormCo ntrols() { Color borderColor = ColorTranslator .FromHtml("#F5F 5F5"); Color fontColor = borderColor; Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls) { if(control is TextBox || control is DropDownList || control is Button) { WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id; webControl.Bord erWidth = 1; webControl.Bord erColor = borderColor; webControl.Fore Color = fontColor; webControl.Back Color = backgroundColor ; } } } </code>
Problem is, the 'this.Controls' collection only has a count of 1, but I have over 45 textboxes alone! So obviously, I'm hitting the wrong collection, but as I inspected this.Controls while debuggin I didn't understand how I was looking at a MasterPage control as the only control in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this way. I can get the dropdowns to work with my CSS, but the textboxes refuse. Just for kicks, here is my CSS: .input, select { background: #1E1E1E; color: #F5F5F5; border: 1px solid #F5F5F5; }
Thanks for reading, Steve
with a master page you need to first find the contentplacehol der(1) then you
can find the controls on a page. I use a lot of dynamicly created controls
1.1 and switching to 2.0/w master pages threw me till i figured it out.
like this
dim thscontrol as [controltype] =
me.masterpage.f indcontrol("con tententplacehol der").findcontr ol("(whet you
swant to find")
or you should be able to loop through when you find the contentplacehol der.
Hope this helps!
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Steve" wrote:
Hi Ken,
My problem is that in my content page, 'this.Controls' is the master page
control.
So I'm confused given a master control, how am I expected to get to a
content pages' controls? This seems especially odd considering I'm in the
Page_Load event of THE content page.
Maybe I'm still missing something?
Thanks for the reply, I appreciate it!
"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message
news:OC******** *****@TK2MSFTNG P05.phx.gbl...
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of
Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. ..
I'm trying to iterate over all the form controls in my MasterPages
content page. Basically, I've got dropdowns, textboxes, etc that I want
to format in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormCo ntrols()
{
Color borderColor = ColorTranslator .FromHtml("#F5F 5F5");
Color fontColor = borderColor;
Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls)
{
if(control is TextBox || control is DropDownList || control is
Button)
{
WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id;
webControl.Bord erWidth = 1;
webControl.Bord erColor = borderColor;
webControl.Fore Color = fontColor;
webControl.Back Color = backgroundColor ;
}
}
}
</code>
Problem is, the 'this.Controls' collection only has a count of 1, but I
have over 45 textboxes alone! So obviously, I'm hitting the wrong
collection, but as I inspected this.Controls while debuggin I didn't
understand how I was looking at a MasterPage control as the only control
in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really
appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this
way. I can get the dropdowns to work with my CSS, but the textboxes
refuse. Just for kicks, here is my CSS:
.input, select
{
background: #1E1E1E;
color: #F5F5F5;
border: 1px solid #F5F5F5;
}
Thanks for reading,
Steve
i see you are using C# i did a vb reply, but i hope you get the idea.
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Steve" wrote:
Hi Ken,
My problem is that in my content page, 'this.Controls' is the master page
control.
So I'm confused given a master control, how am I expected to get to a
content pages' controls? This seems especially odd considering I'm in the
Page_Load event of THE content page.
Maybe I'm still missing something?
Thanks for the reply, I appreciate it!
"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message
news:OC******** *****@TK2MSFTNG P05.phx.gbl...
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of
Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. ..
I'm trying to iterate over all the form controls in my MasterPages
content page. Basically, I've got dropdowns, textboxes, etc that I want
to format in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormCo ntrols()
{
Color borderColor = ColorTranslator .FromHtml("#F5F 5F5");
Color fontColor = borderColor;
Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls)
{
if(control is TextBox || control is DropDownList || control is
Button)
{
WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id;
webControl.Bord erWidth = 1;
webControl.Bord erColor = borderColor;
webControl.Fore Color = fontColor;
webControl.Back Color = backgroundColor ;
}
}
}
</code>
Problem is, the 'this.Controls' collection only has a count of 1, but I
have over 45 textboxes alone! So obviously, I'm hitting the wrong
collection, but as I inspected this.Controls while debuggin I didn't
understand how I was looking at a MasterPage control as the only control
in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really
appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this
way. I can get the dropdowns to work with my CSS, but the textboxes
refuse. Just for kicks, here is my CSS:
.input, select
{
background: #1E1E1E;
color: #F5F5F5;
border: 1px solid #F5F5F5;
}
Thanks for reading,
Steve
I do get the idea and I feel a bit lame that it's that simple :0)
Maybe I'm not paying close enough attention, I swore the single control
contained in Page.Controls was a MasterPage and not a MasterPageConte nt.
Either way, you solution solved my problem and for that...I thank you.
Have a good one.
"WebBuilder 451" <We***********@ discussions.mic rosoft.comwrote in message
news:D2******** *************** ***********@mic rosoft.com...
>i see you are using C# i did a vb reply, but i hope you get the idea.
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Steve" wrote:
>Hi Ken,
My problem is that in my content page, 'this.Controls' is the master page control. So I'm confused given a master control, how am I expected to get to a content pages' controls? This seems especially odd considering I'm in the Page_Load event of THE content page.
Maybe I'm still missing something?
Thanks for the reply, I appreciate it!
"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message news:OC******* ******@TK2MSFTN GP05.phx.gbl...
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of
Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. .. I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load()
I've added this code to my Page_Load() event <code> private void ConfigureFormCo ntrols() { Color borderColor = ColorTranslator .FromHtml("#F5F 5F5"); Color fontColor = borderColor; Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls) { if(control is TextBox || control is DropDownList || control is Button) { WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id; webControl.Bord erWidth = 1; webControl.Bord erColor = borderColor; webControl.Fore Color = fontColor; webControl.Back Color = backgroundColor ; } } } </code>
Problem is, the 'this.Controls' collection only has a count of 1, but I have over 45 textboxes alone! So obviously, I'm hitting the wrong collection, but as I inspected this.Controls while debuggin I didn't understand how I was looking at a MasterPage control as the only control in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it this way. I can get the dropdowns to work with my CSS, but the textboxes refuse. Just for kicks, here is my CSS: .input, select { background: #1E1E1E; color: #F5F5F5; border: 1px solid #F5F5F5; }
Thanks for reading, Steve
I know the feeling way too well! I'm just glad I was finally able to help
some one around here!
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Steve" wrote:
I do get the idea and I feel a bit lame that it's that simple :0)
Maybe I'm not paying close enough attention, I swore the single control
contained in Page.Controls was a MasterPage and not a MasterPageConte nt.
Either way, you solution solved my problem and for that...I thank you.
Have a good one.
"WebBuilder 451" <We***********@ discussions.mic rosoft.comwrote in message
news:D2******** *************** ***********@mic rosoft.com...
i see you are using C# i did a vb reply, but i hope you get the idea.
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Steve" wrote:
Hi Ken,
My problem is that in my content page, 'this.Controls' is the master page
control.
So I'm confused given a master control, how am I expected to get to a
content pages' controls? This seems especially odd considering I'm in
the
Page_Load event of THE content page.
Maybe I'm still missing something?
Thanks for the reply, I appreciate it!
"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in
message
news:OC******** *****@TK2MSFTNG P05.phx.gbl...
Hi Steve,
You can get the parent control using the Parent property. So,
foreach (Control control in TextBox1.Parent .Controls)
would find the common parent of the controls at the same level of
Textbox1.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
"Steve" <sk**@skle.comw rote in message
news:uT******** ********@TK2MSF TNGP03.phx.gbl. ..
I'm trying to iterate over all the form controls in my MasterPages
content page. Basically, I've got dropdowns, textboxes, etc that I
want
to format in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormCo ntrols()
{
Color borderColor = ColorTranslator .FromHtml("#F5F 5F5");
Color fontColor = borderColor;
Color backgroundColor = ColorTranslator .FromHtml("#0D0 D0D");
foreach(Control control in this.Controls)
{
if(control is TextBox || control is DropDownList || control is
Button)
{
WebControl webControl = control as WebControl;
webControl.Bord erStyle = BorderStyle.Sol id;
webControl.Bord erWidth = 1;
webControl.Bord erColor = borderColor;
webControl.Fore Color = fontColor;
webControl.Back Color = backgroundColor ;
}
}
}
</code>
Problem is, the 'this.Controls' collection only has a count of 1, but
I
have over 45 textboxes alone! So obviously, I'm hitting the wrong
collection, but as I inspected this.Controls while debuggin I didn't
understand how I was looking at a MasterPage control as the only
control
in the collection.
I'm sure one of you know exactly what I'm doing wrong, I would really
appreciate a tip.
BTW, I'm not too skilled in the ol' CSS yes, that's why I'm doing it
this
way. I can get the dropdowns to work with my CSS, but the textboxes
refuse. Just for kicks, here is my CSS:
.input, select
{
background: #1E1E1E;
color: #F5F5F5;
border: 1px solid #F5F5F5;
}
Thanks for reading,
Steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Holmes |
last post by:
I'm using data to rename some web controls on a form that uses a repeater
contol and so it can have mulitple instances of the same control set. The
controls get renamed (thanks to Steven Cheng's help) in a click event of the
button that is pushed to enter data. Each time the button is clicked it
sends the ID entered by the user to query the database and return
information. The renamed controls then include the ID in the name of the...
|
by: Mafuba |
last post by:
I'm trying to use data sources with data bound controls on one of my
pages that's using a master page. The master page has 2
ContentPlaceHolders, and in my page the data sources are in the first
content area, and the data bound controls are in the second. The data
bound controls are having a problem seeing the data sources at run time
(even though everything is picked up by the visual studio at design
time).
I get an error message...
|
by: Michael Herman \(Parallelspace\) |
last post by:
1. What are some compelling solutions for using Master/Content pages with
Web Pages?
2. If a content area has a web part zone with web parts, what is the user
experience like when "editting" the web part page? Does it take place at
the page level? ...or the content area level?
3. Where is the Web Part Manager instantiated? ...in the Master Page?
....Content Page? ...elsewhere?
|
by: multiformity |
last post by:
So I have been working on an opensource project for a while, and
decided to really try to make it look better after focusing on the
functionality most of this time. Up to now, I have simply used a
standard ASPX page with minor modifications to it. All of my pages
inherit from a "BasePage.cs" class, that handles common things like
getting the user's information out of the session, determines if a page
should or should not be password...
|
by: Scott |
last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID:
Content1). Content1 contains several usercontrols, which are hidden. The
goal is to show the correct control based on the querystring passed when
calling mp_TableMaint (the page is called from an ASP.NET 2.0 Menu control
on my index.aspx page). I believe I understand correctly that the Master
Page's ASP Content control (named Content1) is, itself, a server side...
| |
by: Andy |
last post by:
Hey all,
I'm building out my first project using asp.net v2.0 master pages. It seems
that when you use master pages and try to reference document.body.scrollTop
it allways = zero/0. The same code works in a regular .htm file.
Has anyone else seen this?
Anyone know how to get the body.scrollTop property using masterpages.
Thanks for any help
Andy
|
by: dixonjm |
last post by:
Hi,
I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page.
When I try to load the CSS & JS files using the code behind of the content page, my buttons aren't rendered and Im not sure why?
Here is the code for my content page - Properties.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" Title="Properties"...
|
by: Francois |
last post by:
I plan a master page / content page design for next application.
The master page would contain some standard button for my app. For instance
a "Save" button. (present on all pages).
But how can I call code in the content.cs page from the Save_Click in the
master.cs page ?
Thanks.
|
by: =?Utf-8?B?bXVzb3NkZXY=?= |
last post by:
Hi guys
I'm trying to make my code as streamlined as possible, and add CSS file
references dynamically when they are required, for example, if a page
contains a webcontrol, then the related CSS file is added by the webcontrol.
This prevents me having to remember to add the CSS file to the page if I use
a certain webcontrol.
I have a MasterPage with an array of StyleSheets, and a public function for
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |