RE: find control question

Tech-Archive recommends: Fix windows errors by optimizing your registry



a lot of work for a simple task. But i'll try it!
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes


"Yankee Imperialist Dog" wrote:

total bummer here with this i, know! My solution is total over kill here, but
it works

ok, use generics to return a list of controls.
i use this in a name space, but you could just use it for a simple
/// <summary>
/// returns a list of the given controls
/// </summary>
/// <param name="root"></param>
/// <param name="typ"></param>
/// <param name="ControlList"></param>
/// <returns></returns>
public static List<Control> GetAListOfControls(Control root, Type
typ, List<Control> ControlList)
{
foreach (Control t in root.Controls)
{
if (t.GetType() == typ)
ControlList.Add(t);
if (t.Controls.Count > 0)
{
ControlList = GetAListOfControls(t, typ, ControlList);
}
}
return ControlList;
}

then call it thus for the texh boxes:

List<Control> ctrls = new List<Control>();
ctrls = AdminPageHelper.GetAListOfControls(cph, typeof(TextBox), ctls);

from there you got the list loop or use as you see fit.

--



"WebBuilder451" wrote:

i have a master page and aseries of controls labeled fn1, fn2, fn3 , ...

i want ot loop and use find control but i'm finding them.
i'm using the following w/o luck

ContentPlaceHolder cph =
(ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1");

for (int i = 0; i < 7; i++)
{
TextBox tbF = (TextBox)cph.FindControl("tbFN" + i.ToString());
TextBox tbL = (TextBox)cph.FindControl("tbLN" + i.ToString());

........
}

they come up null
where are the controls located??
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes
.



Relevant Pages

  • Re: New Years Dark Week Time Wasting Thread
    ... I don't know what Donz' personal port-a-thing is but I saw one of the ... The Remote Controlled Beverage Cooler. ... underside wheels up to 40 feet from the host at the controls. ...
    (alt.fan.letterman)
  • Re: New Years Dark Week Time Wasting Thread
    ... The Remote Controlled Beverage Cooler. ... This amusing remote-controlled cooler can travel across a patio, rug, or kitchen floor to deliver a well-timed beverage to parched party guests. ... With room for 12 cans or bottles and ice, the cooler rolls on four sturdy underside wheels up to 40 feet from the host at the controls. ... The remote features simple controls that send the cooler forward, backward, and progressively left or right. ...
    (alt.fan.letterman)
  • RE: find control question
    ... total bummer here with this i, ... use generics to return a list of controls. ... typ, ListControlList) ... from there you got the list loop or use as you see fit. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Long live Classic!
    ... I use cooler ... controls now like ListView... ... Man, I can't even imagine redoing all of this stuff in 2005, I don't have ... Mark ...
    (microsoft.public.vb.general.discussion)
  • Re: Objekttypen anhand eines Indexes festlegen...
    ... >> AddHandler o.setMessage, AddressOf SetMessage ... > Welcher Typ hat denn das Event? ... welche Controls dort ihre Events abhandeln... ...
    (microsoft.public.de.german.entwickler.dotnet.vb)