If you have worked with MasterPages in ASP.NET 2.0, you have no doubt been looking at the source of a page, and seen something like the following....
The naming convention of controls following the hierarchy of pages in which the control is nested. When the ID of a masterpage is not explicitly set, it defaults to ctl00. When you add a new MasterPage to a project/website, you get default content like the following...
If you just start going from here, you may be making a mistake. The names you give (or don't give) your MasterPage and ContentPlaceHolders show up twice per control. And you might be appalled if you look at the source for a gridview/detailsview.
Here's the tip:
- Name your contentplaceholders with as short of name as possible. I use "c" for a main content area, "t" for a title, and so on.
- Add the following piece of code to code behind of your MasterPage.
The same example I started with (btnSave) would now look like this in source...
In larger applications, with complex web forms, this little trick may get you a 10% decrease in page size alone!
I wish your code wasn't an image so I could copy and paste :)
ReplyDeleteYet to discover a good way to post code snippets without them being images :-)
ReplyDeleteTry this: http://www.manoli.net/csharpformat/format.aspx.
ReplyDelete