Traversing children controls of user control get extra controls

Discussion in 'ASP .Net' started by df, May 17, 2006.

  1. df

    df Guest

    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?
    df, May 17, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michael
    Replies:
    0
    Views:
    435
    michael
    Feb 24, 2004
  2. mathieu
    Replies:
    3
    Views:
    582
    Bo Persson
    Sep 4, 2009
  3. abcd

    Controls traversing

    abcd, Dec 2, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    301
    Gregory A. Beamer
    Dec 2, 2009
  4. Todd
    Replies:
    0
    Views:
    121
  5. Craig
    Replies:
    9
    Views:
    346
    AlanM
    Mar 29, 2005
Loading...

Share This Page