tags:

views:

111

answers:

2

Hi,

Working in .net 4.0, it still seems all my input controls have the attribute 'name', with a value that begins 'ct100$...'.

Is there any way to rename this?

I've gone all the way up the control hierarchy, and given each control an ID and set its clientidmode to 'Static' to no avail, even the 'earliest' controls on the page still inherit the prefix.

+1  A: 

This is the master page's ID. I change it by adding a Page_Init to my masterpage which sets its id:

Private Sub InitSub(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    ID = "master"
End Sub

This ID is normally empty/null so when it renders it it generates an id (starting at ct100 and going up)

Like @Scott Stafford said, keep it short because it prefixes every client id on your page.

I use words like "mBio", "mHome", etc..

Bob Fincheimer
Thanks bob. It can also be set on Page_Load():protected void Page_Load(object sender, EventArgs e) { ID = "m"; }}
maxp
Page Load might be a little late, I would be safe and do it in init (so that any custom controls have their client ids on their inits)
Bob Fincheimer
A: 

Why rename it? You can, as @Bob Fincheimer describes, but so what? Also, if you DO rename it, keep the new name short, because that name shows up in all generated HTML and all POSTing variables hundreds of times, possibly enough to actually affect performance of your site.

Scott Stafford
Call me anal, but yes, i'm doing it for marginal performance gains (naming it 'm' instead of 'ct100')
maxp