By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,172 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,172 IT Pros & Developers. It's quick & easy.

Naming Container difference between VS2003 and VS2005

P: n/a
I have an ASP.Net project I developed in VS2003 (ASP.Net 1.1) that works
fine, but when I convert it to VS2005 (ASP.Net 2.0) it's behavior seems to
change. I have the following datagrid in my project:

<asp:datagrid id="grid" runat="server" AutoGenerateColumns="False"
AllowSorting="False" DataKeyField="myID">
<Columns>
<asp:TemplateColumn HeaderText="Action">
<ItemTemplate>
'''''''NOTE FOLLOWING LINE:
<input Runat="server" ID="SelectedRequest" type="hidden"
NAME="SelectedRequest" />
'''''''NOTE PREVIOUS LINE ^
<asp:Literal Runat="server" ID="litRadioButtons" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Action Message">
<ItemTemplate>
Message:<br>
<asp:TextBox ID="txtMessage" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

When I run this page in VS2003, the line noted above is rendered as:

<input name="grid:_ctl2:SelectedRequest" id="grid__ctl2_SelectedRequest"
type="hidden" />

But when I run my converted project in VS2005, it is rendered as:

<input name="SelectedRequest" type="hidden" id="SelectedRequest" />

What am I missing here? Why isn't the ID of my input control being modified
by it's naming container?

TIA.

Dec 4 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Monty,

Is this the same code logic as you were using in VS2003 and it worked
correctly?

I have reproduced the issue you mentioned in VS2008. The issue seems
related to accessing the control's ClientID property in the ItemCreated
event. I will do some more research and get back to you later.

Thanks for your feedback.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 7 '07 #2

P: n/a
Hi Monty,

Well, I have just found out it's a known issue of ASP.NET 2.0, we have an
open bug record for it.

Some explanation of this issue:

When ClientID is called, part of the operation is to retrieve the naming
container prefix to return the full client ID (with naming container
prefix), through the calling of UniqueID property. At the time ItemCreated
event is called, the control created in the event has not been added to the
control tree. It is added to the control tree after the event is done in
DataGrid's code. So you observed that ClientID returns only the ID in
ItemCreated event.

In v1.x, the UniqueID is computed everytime the property is called, meaning
that the control would walk up the tree to gather the necessary id prefix
for the naming containers. In v2.0, for better performance, we introduced
some caching code so the control tree walk up would only be done once for
the first time it is being accessed.
As a workaround, we should avoid calling ClientID in ItemCreated event.

If this workaround doesn't work for you, please contact our Customer
Support and Service to see if there will be hotfix available before it's
fully fixed in future versions. We're sorry for the inconvenience caused.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 7 '07 #3

P: n/a
Hi Walter,

Thanks for the research. Do you have KB number for this? Do you know if this
issue is resolved with v3.5?

Thanks again...
Dec 7 '07 #4

P: n/a
For anyone following along, no this issue has not changed in the 3.5
Framework, but I was able to work around this issue by moving my code from
the ItemCreated event to the ItemDataBound event. Good luck!
Dec 9 '07 #5

P: n/a
Hi Monty,

The public KB is under development.

Thanks for your feedback, this will certainly benefit others if they also
encouter this issue.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 10 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.