473,396 Members | 1,770 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.

change an attribute of all controls, before the page renders

i want to enumerate all server controls in a page

if it has a text property, change it

right before the page is sent to the browser

how do i do this?

i take it i have to override something like page.Render()...

thanks!

neil

Mar 23 '06 #1
3 951
q
What attribute? You can very easily iterate in ECMAScript (JavaScript)
as well...

Mar 24 '06 #2
the Text property

i want to do this on the server, not client

Mar 27 '06 #3
There may be an easier way, but if you chose a numeric naming
convention for your fields, than you can loop through them.

e.g.
str1, str2 //for text box
ddl1, ddl2 //for drop down list

CODE...

Page pgPage = this.Page; //or pass the page into the procedure if you
are using a class.

int intControl = 1;
int intControls = 55 //If you have 55 controls on your page

while(intControl <= 55)
{
TextBox strTextBox = pgPage.FindControl("str" + intControl) as TextBox;
strTextBox.Text = "Test"; //Set the value to whatever you want it to be
intControl += 1; //Move to the next control
}

//Repeat for DropDownLists and other control types, e.g.

while(intControl < 55)
{
DropDownList strDropDownList = pgPage.FindControl("ddl" + intControl)
as DropDownList;
strDropDownList.SelectedValue = "Test"; //Set the value to whatever you
want it to be
intControl += 1; //Move to the next control
}

In my application I have a whole load a variables for controls, so I
store them in a database table along with the control ID and perform
the same loop, but through a recordset.

Hope this is useful.

Jared

Mar 27 '06 #4

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

Similar topics

2
by: TJS | last post by:
in a custom control which renders a form, is there a way to define the form action other than the preset postback. I've seen several but they are all an httpModule of sorts. I would like to do...
1
by: Guadala Harry | last post by:
I have a very simple aspx page (no code-behind logic) that hosts two 3rd party controls (a dynamic menu and a calendar). The dynamic menu has the bare minimum number of properties set...
8
by: | last post by:
I have a Custom WebControl which adds several children at OnInit. In OnInit I set the ChildControl to ParentID + "_" + Control's ID so it would be something like MyContainer_VendorID Now the...
2
by: Radu | last post by:
Hi, I have a "select" control named "cboSelectScorecardType", defined as <select id="cboSelectScorecardType" size="1" runat="server"> </select> which shows a list of files on my drive. It...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
tracyyun
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...
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.