user1208480
user1208480

Reputation:

Converting <div> html to <table> html in asp.net

I am making a website in ASP.NET using Visual Studio 2010 and I have a problem. Default programming is in <div> but I want to change into <table> form. Can you help me how can I change it?

I have added the default programming:

<form runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
    My ASP.NET Application
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Index.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="footer">
Thank You for visiting.
</div>
</div>
</form>

I hope you will help me. Thanks.

PN: I was trying to do it but error occurred. So please help. Error says "text is not allowed between the opening and closing tags for element table".

Upvotes: 0

Views: 1179

Answers (1)

Shadow Wizard
Shadow Wizard

Reputation: 66389

HTML table must contains rows and cells, it can't have text of its own. Content can be part of table cells only.

So, to place the three <div> elements of "page" inside a table, each in its own row have such code:

<table>
<tr>
    <td class="header">
        <div class="title">
        <h1>
            My ASP.NET Application
        </h1>
    </td>
</tr>
<tr>
    <td class="loginDisplay">
        <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
            <AnonymousTemplate>
                [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
            </AnonymousTemplate>
            <LoggedInTemplate>
                Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
            </LoggedInTemplate>
        </asp:LoginView>
    </td>
</tr>
<tr>
    <td class="clear hideSkiplink">
        <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
        <Items>
            <asp:MenuItem NavigateUrl="~/Index.aspx" Text="Home"/>
            <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
        </Items>
        </asp:Menu>
    </td>
</tr>
</table>

Upvotes: 1

Related Questions