Take Control Of Web Control ClientID Values in ASP.NET 4.0

Posted on 4 Guys From Rolla See other posts from 4 Guys From Rolla
Published on Wed, 17 Mar 2010 00:00:00 GMT Indexed on 2010/03/17 4:11 UTC
Read the original article Hit count: 683

Filed under:

Each server-side Web control in an ASP.NET Web Forms application has an ID property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side ID value into a client-side id attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side ID property and the generated client-side id, but in reality things aren't so simple. By default, the rendered client-side id is formed by taking the Web control's ID property and prefixed it with the ID properties of its naming containers. In short, a Web control with an ID of txtName can get rendered into an HTML element with a client-side id like ctl00_MainContent_txtName.

This default translation from the server-side ID property value to the rendered client-side id attribute can introduce challenges when trying to access an HTML element via JavaScript, which is typically done by id, as the page developer building the web page and writing the JavaScript does not know what the id value of the rendered Web control will be at design time. (The client-side id value can be determined at runtime via the Web control's ClientID property.)

ASP.NET 4.0 affords page developers much greater flexibility in how Web controls render their ID property into a client-side id. This article starts with an explanation as to why and how ASP.NET translates the server-side ID value into the client-side id value and then shows how to take control of this process using ASP.NET 4.0. Read on to learn more!
Read More >

© 4 Guys From Rolla or respective owner

Take Control Of Web Control ClientID Values in ASP.NET 4.0

Posted on Internet.com See other posts from Internet.com
Published on Wed, 17 Mar 2010 04:00:00 +0100 Indexed on 2010/03/17 15:11 UTC
Read the original article Hit count: 683

Filed under:
This ASP.NET tutorial shows how to take control of the ClientID values generated by Web controls in ASP.NET 4.0 by using the new ClientIDMode property.

© Internet.com or respective owner

Take Control Of Web Control ClientID Values in ASP.NET 4.0

Posted on Dot net Slackers See other posts from Dot net Slackers
Published on Wed, 17 Mar 2010 00:00:00 GMT Indexed on 2010/03/17 4:51 UTC
Read the original article Hit count: 683

Filed under:

Each server-side Web control in an ASP.NET Web Forms application has an ID property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side ID value into a client-side id attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side ID property and the generated client-side id, but in reality things aren't so simple. By default, the rendered client-side id is formed by taking the Web control's ID property and prefixed it with the ID properties of its naming containers. In short, a Web control with an ID of txtName can get rendered into an HTML element with a client-side id like ctl00_MainContent_txtName.

This default translation from the server-side ID property value to the rendered client-side id attribute can introduce challenges when trying to access an HTML element via JavaScript, which is typically done by id, as the page developer building the web page and writing the JavaScript does not know what the id value of the rendered Web control will be at design time. (The client-side id value can be determined at runtime via the Web control's ClientID property.)

ASP.NET 4.0 affords page developers much greater flexibility in how Web controls render their ID property into a client-side id. This article starts with an explanation as to why and how ASP.NET translates the server-side ID value into the client-side id value and then shows how to take control of this process using ASP.NET 4.0. Read on to learn more!
Read More >

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Email this Article

© Dot net Slackers or respective owner

Take Control Of Web Control ClientID Values in ASP.NET 4.0

Posted on Internet.com See other posts from Internet.com
Published on Tue, 16 Mar 2010 04:00:00 +0100 Indexed on 2010/03/17 6:01 UTC
Read the original article Hit count: 683

Filed under:
Each server-side Web control in an ASP.NET Web Forms application has an <code>ID</code> property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side <code>ID</code> value into a client-side <code>id</code> attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side <code>ID</code> property and the generated client-side <code>id</code>, but in reality things aren't so simple. By default, the rendered client-side <code>id</code> is formed by taking the Web control's <code>ID</code> property and prefixed it with the <code>ID</code>

© Internet.com or respective owner