This project is read-only.

The main idea is to use ControlAdapter that will care about ClientIDs.
You need four steps to make it work.


Step 1: Download Project source files.
Its just two files: NoIdAdapter.cs and NoIdAdapter.browser

Step 2: Add specialized ASP.NET folder named "App_Browsers".
To do this, right click on your Project in Solution Explorer and add it:

App_Browsers folder

Step 3: Add file NoIdAdapter.cs to your project.

Step 4: Place file NoIdAdapter.browser into "App_Browsers" folder and include it to Project.

That's it!

Now you have special attribute "noid" that you can add to controls. If you set it to "true" or "True" - ClientID will be not rendered for this control.


  • Attribute Name and its values are case-sensitive - this was done for maximal performance. ControlAdapter will check for this attribute for almost all controls on the Page. So this check must be very fast.
  • ContolAdapter handles only controls that not support interfaces IPostBackDataHandler and IPostBackEventHandler. Exception was made only for Table control - it implements IPostBackEventHandler interface but attribute "noid" will work for it.

You can use this attribute declarative in binding (assuming we have protected bool field named "NoIds"):

<asp:Repeater ID="repeater" runat="server">
        <asp:Panel ID="mainPanel" runat="server" noid='<%# NoIds %>' CssClass="panel">
            <asp:Panel ID="childPanel" runat="server" noid='<%# NoIds %>'>
                <div id="oneMorePanel" runat="server" noid='<%# NoIds %>'>
                    <asp:Label ID="someLabel" runat="server" noid='<%# NoIds %>' Text="Top Label"/><br />
                    <asp:HyperLink ID="hyperLink" runat="server" noid='<%# NoIds %>' NavigateUrl="" >
                        <asp:Image ID="someImage" runat="server" noid='<%# NoIds %>' ImageUrl="/img/img.png" /><br />
                        <asp:Table ID="table" runat="server" noid='<%# NoIds %>'>
                            <asp:TableHeaderRow ID="headerRow" runat="server" noid='<%# NoIds %>'>
                                <asp:TableHeaderCell ID="headerCell" runat="server" noid='<%# NoIds %>'>
                                    <asp:Label ID="label" runat="server" noid='<%# NoIds %>'>Test</asp:Label>

Or set it from CodeBehind (assuming we have protected bool field named "NoIds"):

someControl.Attributes.Add("noid", NoIds.ToString());

Last edited Jun 8, 2011 at 3:44 PM by Lisetsky_Val, version 4


No comments yet.