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

Search through controls in Page

Hi all,

I think i'm missing something here.

I have a page with a number of textboxes in it and I simply want to
enable or disable them on a button click. I first search through page:

foreach (Control ctrl in Page.Controls)

and then to check their type I:

Response.Write(ctrl.GetType().ToString() + "<br/>");

Every control is given as type "System.Web.UI.LiteralControl", and so i
cannot cast to WebControl and access the Enabled property. None of the
controls are in panels, so the above should see them?
What am I doing wrong here? Any help would be appreciated;

Jun 15 '06 #1
3 831
Search the Form instead of the Page.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

"^MisterJingo^" <mi*********@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi all,

I think i'm missing something here.

I have a page with a number of textboxes in it and I simply want to
enable or disable them on a button click. I first search through page:

foreach (Control ctrl in Page.Controls)

and then to check their type I:

Response.Write(ctrl.GetType().ToString() + "<br/>");

Every control is given as type "System.Web.UI.LiteralControl", and so i
cannot cast to WebControl and access the Enabled property. None of the
controls are in panels, so the above should see them?
What am I doing wrong here? Any help would be appreciated;

Jun 15 '06 #2

^MisterJingo^ wrote:
Hi all,

I think i'm missing something here.

I have a page with a number of textboxes in it and I simply want to
enable or disable them on a button click. I first search through page:

foreach (Control ctrl in Page.Controls)

and then to check their type I:

Response.Write(ctrl.GetType().ToString() + "<br/>");

Every control is given as type "System.Web.UI.LiteralControl", and so i
cannot cast to WebControl and access the Enabled property. None of the
controls are in panels, so the above should see them?
What am I doing wrong here? Any help would be appreciated;


I just tried the following and it seemed to work:

foreach(Control ctrl in Page.FindControl("form1").Controls)

Jun 15 '06 #3
Kevin Spencer wrote:
Search the Form instead of the Page.

--
HTH,

Hi Kevin,

I just worked that out, thanks :). I think I need more caffeine this
morning!

Jun 15 '06 #4

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

Similar topics

4
by: James | last post by:
Why does my LDAP query from a C# console app limit its results to 1000? When I run the same query from a vb script I get over 6000 results. I have tried to set the SearchRequest.SizeLimit to a...
1
by: Mike | last post by:
I have a search page that I want to enable private caching so that when a user hits the back button they dont get the page has expired error. I have seen this done on: ...
2
by: Peter Morris [Droopy eyes software] | last post by:
Hi all I want to put a google search on my website. My options are 1) Create a new <form> outside of my aspx form. Problem: I have a HeaderControl and FooterControl on each page to give my...
1
by: Henrik | last post by:
Hello all. I'm after some sort of pagination function. One that takes some in data that I provide, and returns an array of controls, pointing to page 2, page 3 etc. Trying to mimic the way that...
5
by: Jens Jensen | last post by:
Hello, Does anyone know anything about how to optimise asp.net 2.0 pages for search engines? I'm thinking of a programmatic way of mapping sitemap structure to pages meta tags. Well it...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
1
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
3
by: yogarajan | last post by:
Dear Friends i am devloping for search box it is woking good i want highlight my search text. My original text is Mixed case (Lower case and upper case) my search text is lower case means how can...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...

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.