[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net, html5 validation question...

Posted on 2014-08-25
4
Medium Priority
?
693 Views
Last Modified: 2014-08-26
The following line is from Default.aspx:
     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StatTypeID" DataSourceID="SqlDataSource1">

The following line is the matching html from visual studio 2010 (with validation set to html5):
     <table id="GridView1" cellspacing="0" rules="all" border="1" style="border-collapse:collapse;">

Question: How can I handle the following errors:
Error: The cellspacing attribute on the table element is obsolete. Use CSS instead.
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Error: The rules attribute on the table element is obsolete. Use CSS instead.
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Warning: The border attribute on the table element is presentational markup. Consider using CSS instead. For example: table, td, th { border: 1px solid gray }
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Open in new window

When I use:
#GridView1
{
    color:Red;
    border-collapse:collapse;
    border:1px solid green;
rules:all;       /*  <-- not recognized */
}

Open in new window

some attributes are handled but It is not clear what I should write for cellspacing="0" for css to recognize it.

Thank you.
0
Comment
Question by:Mike Eghtebas
  • 2
4 Comments
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 800 total points
ID: 40283943
table {
    border-spacing: 0;
    border-collapse: collapse;
}

Should do it for you.

Cd&
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40284040
Hi Cd&,

Thank you for the solution. I am still getting the errors because the rendered page is including inline styling which overwrites any external CSS.

How can I make the grid view not to include these inline attributes?

FYI, I have used gridview from the toolbar; perhaps I need not to use gridview from the tollbar. Instead, I may have to populate this gridview from codebehinde to have a better control on its styling.

If this seems a workable solution, please give me some lines of code to get it started in this direction.

Thanks again,

Mike

Here is .aspx file incase you like to see it:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <meta charset="utf-8" />
    <link href="style/form1through6.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1"  runat="server" AutoGenerateColumns="False" 
            DataKeyNames="StatTypeID" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="Sort" HeaderText="Sort" SortExpression="Sort"/>
                <asp:BoundField DataField="CurrYearCount" HeaderText="CurrYearCount" 
                    SortExpression="CurrYearCount"/>
                <asp:BoundField DataField="LastYearCount" HeaderText="LastYearCount" 
                    SortExpression="LastYearCount"/>
                <asp:BoundField DataField="PI" HeaderText="PI" ReadOnly="True" 
                    SortExpression="PI"/>
                <asp:BoundField DataField="StatTypeID" HeaderText="StatTypeID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="StatTypeID"/>
                <asp:BoundField DataField="YYYY" HeaderText="YYYY" SortExpression="YYYY"/>
                <asp:BoundField DataField="StatType" HeaderText="StatType" 
                    SortExpression="StatType"/>
                <asp:CheckBoxField DataField="ExcludeYN" HeaderText="ExcludeYN" 
                    SortExpression="ExcludeYN"/>
                <asp:BoundField DataField="Region_ID" HeaderText="Region_ID" 
                    SortExpression="Region_ID"/>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ROD_July18ConnectionString %>" 
            SelectCommand="spAuunuaCountMedCtr" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="2" Name="StatType_ID" Type="Int32" />
                <asp:Parameter DefaultValue="2014" Name="YYYY" Type="String" />
                <asp:Parameter DefaultValue="1" Name="RegionID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40284120
I show up with an asp certification, but that is based on helping with HTML and CSS problems posted in the asp topic.  I am definitely not and ASP expert. So I don't know what to suggest here.  I never let use anything that generates things I do not explicitly request.

So about the best I can suggest is to do direct coding to replace anything that is forcing undesireable code in the page.

Sorry I can be more help; I've sent a message to another Expert who is more ASP oriented to see if they can follow up.

Cd&
0
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1200 total points
ID: 40284434
I don't use .net either (just the old fashioned classic asp or php).  However, I think you need to set things like cell spacing and padding to -1 http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.cellspacing(v=vs.110).aspx

I don't have access to my testing server to try this out but give it a try and see if it will get rid of those items.   Then you can use pure css.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question