Traversing children controls of user control get extra controls

D

df

The user control can not be much simple:

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="SortOnListByClass.ascx.cs" Inherits="SortOnListByClass" %>
<asp:HyperLink ID="SortOnName" Text="Name" NavigateUrl="Name"
runat=Server/>

The traversing code is simple too:

protected void Page_Load(object sender, EventArgs e){
if(IsPostBack){
return;
}
foreach(Control Ctrl in Controls){

Response.Write(Ctrl.ToString();
}
}

But the resoult will get 2 controls:One is the real HyperLink,and
another is a Literal Control.Where does it come from?
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top