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. Advertisements

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. =?Utf-8?B?REo=?=
    Replies:
    2
    Views:
    615
    =?Utf-8?B?REo=?=
    Dec 1, 2005
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    884
    Mad Scientist Jr
    Mar 22, 2006
  3. mathieu
    Replies:
    3
    Views:
    918
    Bo Persson
    Sep 4, 2009
  4. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    801
    Jonathan Wood
    Feb 2, 2010
  5. Todd
    Replies:
    0
    Views:
    187
  6. Faizan Ahmed
    Replies:
    1
    Views:
    482
    John Saunders
    Jan 4, 2005
  7. Craig
    Replies:
    9
    Views:
    538
    AlanM
    Mar 29, 2005
  8. Faizan Ahmed
    Replies:
    1
    Views:
    515
    John Saunders
    Jan 4, 2005
Loading...