looping through UserControl

K

Kevin Blount

I have a user control I'm planning on using, but I need to dynamically
set one property of each control. The ASPC page uses a Master Page, and
it's the same property (in this case), but I cannot figure out how to
loop through the user controls.

For example, here's my APSX page:

<%@ Page Language="C#" MasterPageFile="~MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="ccare_Default" Title="Untitled Page" %>

<%@ Register Src="~/UserControls/ajaxInputText.ascx"
TagName="formControls" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<uc1:formControls ID="Name" runat="server" FieldName="Name"
TableName="" DatabaseName="myDB" />

<uc1:formControls ID="Email" runat="server" FieldName="Email"
TableName="" DatabaseName="myDB" />

</asp:Content>

So in the example above, I'd be looking to pass the TableName property
to each control (assuming, for the example, that is it determined by
something else, such as as a querystring value)


What would be the C# for looping trough these user controls? I've tried
foreach loops looking at this.Page.Controls, this.Form.Controls, etc..
but I can't find one that give me what I expect. I'm sure there's some
recursive issue here, but I'm lost on how to do that too.

Hopefully uo can see I've been researching this, and I really want to
know this information (even if I use something else eventually), so I'm
not looking for altertives just yet. I just need to know how to set one
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top