Strange Source

R

rn5a

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="dgMarks" 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.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top