Removing </p> tag after ValidationSummary control
I use Visual Studio 2010 in ASP.NET with C# code behind.
I have an ASP.NET page with code in Source View:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</p>
If I switch in Design View and come back to Source View in VS, it unexpectedly removes the last </p>
automatically.
Do you have the same problem in your Visual Studio? Any ideas how to solve it?
Thanks.
P.S. Here my full code:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h1>
Create Groups Types</h1>
<p>
<asp:DetailsView ID="uxCreateGroupsTypesDisplayer" runat="server" AutoGenerateRows="False"
DataKeyNames="GroupTypeId" DataSourceID="uxEntityDataSourceCreateGroupsTypes"
DefaultMode="Insert"
oniteminserted="uxCreateGroupsTypesDisplayer_ItemInserted"
oniteminserting="uxCreateGroupsTypesDisplayer_ItemInserting">
<Fields>
<asp:TemplateField HeaderText="TypeGroup" SortExpression="TypeGroup">
<InsertItemTemplate>
<asp:TextBox ID="uxTypeGroupInput" runat="server" Text='<%# Bind("TypeGroup") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="TypeGroup field is required."
ControlToValidate="uxTypeGroupInput" Text="*">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="uxRegularExpressionTypeGroup" runat="server"
ControlToValidate="uxTypeGroupInput" ErrorMessage="TypeGroup is too long or short. Change the field accordingly."
ValidationExpression="^.{4,40}$">*</asp:RegularExpressionValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Summary" SortExpression="Summary">
<InsertItemTemplate>
<asp:TextBox ID="uxSummaryInput" runat="server" Text='<%# Bind("Summary") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorSummary" runat="server" ErrorMessage="Summary field is required."
ControlToValidate="uxSummaryInput" Text="*">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="uxRegularExpressionSummary" runat="server" ControlToValidate="uxSummaryInput"
ErrorMessage="Summary is too long or short. Change the field accordingly." ValidationExpression="^.{4,256}$">*</asp:RegularExpressionValidator>
开发者_如何学Go </InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</p>
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /></p> <!-- The problem is here - This tag disappear if you switch from source view to design view and back to source view -->
<asp:EntityDataSource ID="uxEntityDataSourceCreateGroupsTypes" runat="server"
EnableFlattening="False"
EnableInsert="True" EntitySetName="CmsGroupsTypes">
</asp:EntityDataSource>
</asp:Content>
In VS2008, replaced:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /></p>
With:
<p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"></asp:ValidationSummary></p>
This works, although does not agree with the closing tag in markup. Rendering is correct though in IE8.
Why does this summary control need to be enclosed in a paragraph tag? The Validation Summary renders as a block element.
Don't use Design View to edit markup, always use Source View, i.e. markup itself to edit markup.
IMO Design View just a simple, read-only, verify-purpose view.
精彩评论