Need a workaround for .Net Master Page Name Mangling

I am evaluating the conversion of an old asp.net website based on a set of frames to use master pages. The only thing that holds me back is the tremendous work that it will take to refresh each page to cope with the name change. Most of my problems are related to javascript referencing hardcoded Id.

Is there a way to tell ASP.Net that for a specific content area, I don't want an error to occur. Leave it to me to deal with name conflicts.

Note

I know .Net 4.0 has a solution for this as detailed here . I want a solution that is not related to expectation to be .Net 3.5.

Update

Any suggestions on open source alternatives for master pages that get me to .Net 4.0? Or how about solving a hacking problem to get around the mechanism. Thanks

+4
source share
2 answers

The only โ€œsupportedโ€ way to do this is NOT to use elements that are defined as โ€œrunat =โ€œ server. โ€Otherwise, .NET 4.0 is the first time you have a consistent, supported mechanism for making this change.

You may be able to get around this with other means, but nothing that will be easy or quick to implement.

+3
source

One way to do this is to create a generated JavaScript server that associates the generated identifier with a friendlier name. You can access the generated identifier using the ClientID property. For instance:

<asp:Label runat="server" ID="myInfo" Text="Initial text" /> <script type="text/javascript"> function RegObj(clientId, anId) { eval('window.' + clientId + ' = document.getElementById(anId)'); } RegObj('mytext', '<%= myInfo.ClientID %>'); mytext.innerHTML = 'my text'; </script> 

This message identifier includes any manipulation performed using master pages, nested controls, etc.

0
source

All Articles