We have been using ClientID’s in ASP.NET 2.0/3.5 that makes each control to generate the unique client side id attribute to that page or browser. But these ID’s were long and randomly generated. Developers who work on Client-Side programming that uses Java Script, JQuery or Ajax have been suffering a lot spending considerable amount of time when it they need to reference those ClientID’s in the client side scripts. Now the good news is that, ASP.NET 4.0 comes with new ClientIDMode property, gives full control to the developer on the ClientID’s generated by ASP.NET controls. ClientIDMode can take the following four possible valuesAutoID - ASP.NET generate IDs as it does in v3.5 and earlier versions.
Static - ASP.NET use exactly the same ID given to the server control for its client-side ID.
Predictable - ASP.NET try to generate IDs that are guessable from looking at the structure of the page.
Inherit - ASP.NET generate a client-side ID for the page or control using the same ClientIDMode as its parent. i.e. the client ID gets inherited from the parent control.
You can set this property in 3 ways1.Control Level2.Page Level3.Application LevelSetting ClientIDMode at Control LevelEach and every server control in ASP.NET 4.0 has this property and the default value is inherit. <asp:panel id="pnl" runat="server" cssclass="newStyle1" ClientIDMode ="Static"> </asp:panel>Setting ClientIDMode at Page Level<%@ Page Language="C#" ClientIDMode ="Inherit" AutoEventWireup="true" CodeBehind="Category.aspx.cs" Inherits="WebApplication3.Cat" %> Setting ClientIDMode at Application LevelYou need to set it at System.Web section of Web.config<system.web>
<pages clientIDMode="Predictable">
</pages>
</system.web> Read more: Beyond Relational
Static - ASP.NET use exactly the same ID given to the server control for its client-side ID.
Predictable - ASP.NET try to generate IDs that are guessable from looking at the structure of the page.
Inherit - ASP.NET generate a client-side ID for the page or control using the same ClientIDMode as its parent. i.e. the client ID gets inherited from the parent control.
You can set this property in 3 ways1.Control Level2.Page Level3.Application LevelSetting ClientIDMode at Control LevelEach and every server control in ASP.NET 4.0 has this property and the default value is inherit. <asp:panel id="pnl" runat="server" cssclass="newStyle1" ClientIDMode ="Static"> </asp:panel>Setting ClientIDMode at Page Level<%@ Page Language="C#" ClientIDMode ="Inherit" AutoEventWireup="true" CodeBehind="Category.aspx.cs" Inherits="WebApplication3.Cat" %> Setting ClientIDMode at Application LevelYou need to set it at System.Web section of Web.config<system.web>
<pages clientIDMode="Predictable">
</pages>
</system.web> Read more: Beyond Relational
0 comments:
Post a Comment