Copy and Past in Visual Studio and Fix IDs

When you copy a big chunk of ASP.NET code the chances are you are going to run int IDs problem. IDs from the new code is wiped as soon as you past them. Here is a solution to fix it.

Copy the chuck of code into clipboard and past into “Sublime Text 2” for example. Use the following RegPater to call all IDs.

Use the following patter in the replace text

Make sure you have select “Regular Expression” (there is a short cut button for it).
Replace everything it finds. And the copy and past the new code. This should fix the problem.

If your code has control validator, use the following regex as a second run to fix that issues

Please note, do not leave – character in ID as Visual Studio will automatically wipe that out.

Leave a Reply

Your email address will not be published. Required fields are marked *