Search This Blog

Tuesday, July 5, 2011

What is client ID mode in asp.net 4.0

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 values
  • AutoID / Legacy - 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 ways
1.Control Level
2.Page Level
3.Application Level

Setting ClientIDMode at Control Level
Each and every server control in ASP.NET 4.0 has this property and the default value is inherit.
1.<asp:panel id="pnl" runat="server" cssclass="newStyle1"
2.ClientIDMode ="Static"> </asp:panel>
Setting ClientIDMode at Page Level
1.<%@ Page Language="C#" ClientIDMode ="Inherit"
2.AutoEventWireup="true"
3.CodeBehind="Category.aspx.cs"
4.Inherits="WebApplication3.Cat" %>
Setting ClientIDMode at Application Level
You need to set it at System.Web section of Web.config
1.<system.web>
2.<pages clientIDMode="Predictable">
3.</pages>
4.</system.web>

7 comments:

  1. Really an awesome post. I wondered by reading this blog post. Thanks a lot for posting this unique post which you have shared with us. Keep on posting like this exclusive post with us.

    Best Seo Services in Chennai

    ReplyDelete
  2. you are posting a good information for people and keep maintain and give more update too.
    seo services india

    ReplyDelete
  3. I really liked this part of the article, with a nice and interesting topics have helped a lot of people who do not challenge things people should know... you need more publicize this so many people who know about it are rare for people to know this......
    Software Testing Training in Chennai
    SEO Training in Chennai
    Informatica Training in Chennai
    Digital Marketing Training in Chennai

    ReplyDelete
  4. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
    It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
    This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
    Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
    Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.

    r-programming Training in rajajinagar

    r-programming Training in bangalore

    Rprogramming Training in velachery

    Rprogramming online Training

    Rprogramming Training

    r-programming Training in Bangalore

    ReplyDelete