Reputation: 934
Has anyone ever experimented with using a GUID for ClientIDs. The reason I am asking is because I have a very UI rich app and the HTML that is sent back and forth is getting bigger and bigger. A big chunk of that HTML is the control ids which are build based on the concatenation of parents. For example: Container_Tab_FirstTab_Control.
One possible solution to this would be to generate GUIDs as ClientID. This way the ClientID will at most be 32 characters long.
Has anyone ever tried something like this before?
I am on .NET 4.0
Upvotes: 0
Views: 1852
Reputation: 32704
If you have too many controls on your page, it might be time to rethink your architecture rather than getting a miniscule bit of better performance from shorter ID's.
Page your data (load it via AJAX). You can also load entire sections of your page via Ajax and build up a dynamic web page.
Upvotes: 1
Reputation: 223287
You can use ClientIDMode
enumeration and specify static
. But then you will have to manage the uniqueness of each control's ClientID.
Using GUID won't be such a good idea because it would be difficult to access them in client side code. You will be required to maintain a mapping between GUID and which control it corresponds to.
But you should really think whether having a lengthy client ID is really that bad for your page performance. Instead of worrying about the client ids you should find a way to limit number of controls/data to be displayed on the page, implement something like paging.
Upvotes: 2
Reputation: 59252
That is generally a bad idea.
But if you are interested, you can set ClientIDMode
property to Static
, which will not change the id.
The id will remain the same.
Upvotes: 0