Strange Source

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Dec 8, 2006.

  1. Guest

    A ASP.NET page has only a DataGrid control whose ID is "DGrid1". The
    Page_Load sub looks like this::

    Sub Page_Load(.....)
    'binding the DataGrid
    'to some data source

    Dim child As Control
    For Each child In DGrid1.Controls
    'Response.Write(child.GetType())
    Response.Write(child.ClientID)
    Next
    End Sub

    <asp:DataGrid ID="DGrid1" AutoGenerateColumns="false"
    BorderColor="dodgerblue" CellPadding="1" CellSpacing="1"
    EnableViewState="true" GridLines="both"
    HeaderStyle-BackColor="dodgerblue" HeaderStyle-Font-Bold="true"
    HeaderStyle-Font-Names="courier new" HeaderStyle-Font-Size="smaller"
    HeaderStyle-ForeColor="white" HeaderStyle-HorizontalAlign="center"
    ItemStyle-Font-Names="courier new" ItemStyle-Font-Size="smaller"
    ShowFooter="false" Width="500" runat="server">

    Note that the first Response.Write line is commented.

    Now when I have a look at the source code of the ASPX page (by
    navigating to "View"---->"Source" menu in IE6.0), then the
    corresponding HTML of the DataGrid is this:

    <table id="DGrid1_ctl00" cellspacing="1" cellpadding="1" rules="all"
    border="1" id="DGrid1" style="border-color:DodgerBlue;width:500px;">

    Note that the HTML <table> has 2 "id" attributes - 'DGrid1_ctl00' &
    'DGrid1'. Next I uncomment the first Response.Write line & comment the
    second Response.Write line in the above code. Then the corresponding
    HTML source of the DataGrid turns out to be

    <table cellspacing="1" cellpadding="1" rules="all" border="1"
    id="DGrid1" style="border-color:DodgerBlue;width:500px;">

    In this case, the HTML <table> has only 1 "id" attribute.

    Now why this discrepancy in the source code?

    Note that the page behavior remains the same under both circumstances.
    , Dec 8, 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. ~~~ .NET Ed ~~~
    Replies:
    1
    Views:
    4,175
    Cowboy \(Gregory A. Beamer\)
    Feb 26, 2005
  2. Developwebsites

    strange source code

    Developwebsites, Aug 7, 2003, in forum: HTML
    Replies:
    3
    Views:
    404
    Jeremy Williams
    Aug 7, 2003
  3. Harvey Twyman
    Replies:
    8
    Views:
    549
    August Derleth
    Oct 25, 2003
  4. Strange Source

    , Dec 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    289
  5. Jason
    Replies:
    3
    Views:
    95
    George Hester
    Nov 3, 2004
Loading...

Share This Page