Go with the flow (layout)
Jeff Key has a handy tip on removing the /// comments for the default C# project templates in VS 2003. While I don't like the comments, my pet peeve is that ASP.NET uses “Grid“ layout by default. For your sanity, below are the directions for how to “go with the flow“.
Changing ASP.NET Pages from grid layout to flow layout
- Navigate to the following directory:
“C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddWebFormWiz\Templates\1033“ (assuming C: installation and english version (aka 1033) - Before changing any templates it's a good idea to make backup copies of them :)
- Open “webform1.aspx” using Notepad, and remove the MS_POSITIONING attribute from the body tag as shown below:
<%@
Page language="c#" Codebehind="$FILENAME$.cs" AutoEventWireup="false" Inherits="$INHERITS$" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><html>
<head>
<title> [!output SAFE_ITEM_NAME] </title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="[!output DEFAULT_CLIENT_SCRIPT]">
<meta name=vs_targetSchema content="[!output DEFAULT_TARGET_SCHEMA]">
</head><body MS_POSITIONING="[!output DEFAULT_HTML_LAYOUT]">
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
Voila! You're done!
Removing Body positioning on a per-project basis
If you don't want to mess with the template documents, or you like Grid layout (I'll withold judgement of you, really) for certain applications, you can change the behavior for new files on a per project basis in Visual Studio by right clicking on the project name (Ex: “WebApplication1)” in Solution Explorer, and select “Properties”. This brings up the project properties window, under Common Properties>>Designer Defaults>>Page Layout change “Grid” to “Flow”.
Comments
- Anonymous
March 30, 2004
Funny you mention that -- just yesterday I noticed that "flow" layout is the default in the V05 preview. Bravo! - Anonymous
March 30, 2004
Actually, what I'd really like would to also have the option at project level to use "%" in positioning by default - I know you can change it afterwards in the HTML but that's a pain.
And "%" is very handy for arranging things in an adaptable manner.
Sort of. - Anonymous
March 30, 2004
Jeff - I'd love to get credit for that one, but it wasn't me, I'm happy that it's the default though :) - Anonymous
March 30, 2004
Why not just change the project-level default instead of the template? (See http://groups.google.com/groups?selm=e8piMQggDHA.2352%40TK2MSFTNGP09.phx.gbl&rnum=2 for details.) This would allow propagation of the prefered default to any other file types that use the same layout-selection mechanism without requiring additional template modifications. - Anonymous
March 30, 2004
Dan,
This is a good tip, but I feel that it can be expanded for the general case. I've been modifying the template files for projects for a while now in C#, especially for new classes. It has much more commenting.
I've even gone so far as to inject my own variables into the template (the easiest example being the date and the time that the file was generated in the comments) through the common.js file that the IDE uses to generate the file.
- Nick - Anonymous
September 27, 2006
Pls let me know how to move controls in .net 2005(asp.net)
ie how to change the postion from one place to another or how to drag a control freely in a form - Anonymous
January 22, 2007
re PageLayout Property for Web Applications. Following the instructions in "Special Edition Using Microsoft Visual Basic.NET" published by QUE, I constructed a grid-based web form containing lables, text boxes and a link button. It compilied error-free and IE displays a window after I click Debug/Start. However IE displays the label text at the top of the window in linear format instead of positioned where I defined it in mid form. The text boxes are not visible. The HTML has "body MS_POSITIONING="GridLayout"> This happened under IE6 and IE7 and under XP Professional and XP Home version. I purchased my copy of VB.NET "Standard" back in 2001 or 2002. What am I doing wrong?