How to implement DIV for this table structure - asp.net

I am trying to replicate this table structure by using div.
<asp:Table ID="tblAnnualReportServiceForm" runat="server" Width="100%" CellSpacing="1" CellPadding="5">
<asp:TableRow >
<asp:TableCell HorizontalAlign="Left">
<asp:Table ID="Table1" runat="server" CellSpacing="1" CellPadding="5">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtStartDate" Width="130px" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow >
<asp:TableCell>
<asp:Label ID="lblEndDate" runat="server" Text="End Date"></asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtEndDate" runat="server" Width="130px" style="text-align:left" ValidationGroup="MKE" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
I have tried the following DIV and I haven't have much CSS experience.
<div>
<div style="float:left">
<asp:Label ID="Label1" runat="server" Text="Start Date"></asp:Label>
</div>
<div>
<asp:TextBox ID="TextBox1" Width="130px" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="Label2" runat="server" Text="End Date"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="130px" style="text-align:left" ValidationGroup="MKE" />
</div>
</div>
Any pointers would be of great help. I have too many table structure that needs to be converted to DIV. I appreciate the help

A general structure to replicate table is like.
<!--table-->
<div>
<!--tr-->
<div style="clear:both"></div>
<!--td-->
<div style="float:left">
</div>
<!--td-->
<div style="float:right">
</div>
<!--tr-->
<div style="clear:both"></div>
<!--td-->
<div style="float:left">
</div>
<!--td-->
<div style="float:right">
</div>
<!--tr-->
<div style="clear:both"></div>
</div>

You can do something like this:
<div>
<div style="clear:both;">
<div style="float:left;width:50%;">
<asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
</div>
<div style="float:left;width:50%;">
<asp:TextBox ID="txtStartDate" Width="130px" runat="server"></asp:TextBox>
</div>
</div>
<div style="clear:both;">
<div style="float:left;width:50%;">
<asp:Label ID="lblEndDate" runat="server" Text="End Date"></asp:Label>
</div>
<div style="float:left;width:50%;">
<asp:TextBox ID="txtEndDate" runat="server" Width="130px" style="text-align:left" ValidationGroup="MKE" />
</div>
</div>
</div>
If you want to get some paddings/margins you can add another div into a cell div:
<div style="float:left;width:50%;">
<div style="border:solid 1px black;padding:5px;margin:1px;">
<asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
</div>
</div>
JsFiddle DEMO or here is a demo with classes (using style is not a very good idea, so I created few classes and removed styles from div tags)

Check out:
1.) YUI Grids - for Tableless design
The foundational YUI Grids CSS offers four preset page widths, six preset templates, and the ability to stack and nest subdivided regions of two, three, or four columns. The 4kb file provides over 1000 page layout combinations.
2.) 960 Grid System: The premise of the system is ideally suited to rapid prototyping, but it would work equally well when integrated into a production environment. There are printable sketch sheets, design layouts, and a CSS file that have identical measurements.

Related

cant get text boxes to fill a panel

so i have this bit of asp here:
<asp:Panel runat="server" ID="pnlNavigator" CssClass="panel panel-primary">
<div class="panel-body" style="width:100%">
<div style="display:inline-block" >
<br /><br />
<div class="container" style="display:inline-block">
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text=" ***Teacher Training, CPD, Mentor Training***">
</asp:TextBox>
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
<asp:TextBox runat="server" Enabled="false" Width="33%" TextMode="MultiLine" Text="***Professional Development, Consultant***">
</asp:TextBox>
</div>
</div>
</div>
</asp:Panel>
and basically they aren't filling up the entire panel,they're only reaching about half way then starting a new line underneath, any help?
Bootstrap .css adds a pixel ::before and ::after the elements so the combined width of the three textareas exceeds 100%.
1st solution: decrease the width by 1%
<asp:TextBox runat="server" Enabled="false" Width="32%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
2nd solution: use bootstrap grid system to control layout
<asp:Panel runat="server" ID="pnlNavigator" CssClass="panel panel-primary">
<div class="panel-body">
<%-- style="width:100%">--%>
<div class="container-fluid">
<%-- style="display:inline-block" >--%>
<%-- <br /><br />--%>
<div class="row">
<%-- style="display:inline-block">--%>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text=" ***Teacher Training, CPD, Mentor Training***">
</asp:TextBox>
</div>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text="***Sports Science, steps, FMS facilitator***">
</asp:TextBox>
</div>
<div class="col-sm-4">
<asp:TextBox runat="server" Enabled="false" Width="100%" TextMode="MultiLine" Text="***Professional Development, Consultant***">
</asp:TextBox>
</div>
</div>
</div>
</div>
</asp:Panel>

How can I align two asp.net textboxes beside each other with Bootstrap?

I want to have the two text boxes below Account to be align horizontally. I've tried using different amounts of columns but I cannot seem to get them to change from being stacked on top of each other. I have a link to a prototype that I quickly made it Adobe Xd of how I want the textboxes to look.
This is what I have:
This is what I want it to look like:
This is the code i have right now
<div class="form-group">
<asp:Label ID="lblwk_num" runat="server" AssociatedControlID="txtwk_num" Text="Work Order #" CssClass=""></asp:Label>
<asp:TextBox ID="txtwk_num" runat="server" ReadOnly="True" CssClass="form-control" Enabled="False"></asp:TextBox>
</div>
<div class ="form-group">
<asp:Label ID="lblwk_acct" runat="server" AssociatedControlID="txtwk_acct" Text="Account" ></asp:Label>
<asp:TextBox ID="txtwk_acct" ReadOnly="True" Enabled="False" CssClass="form-control" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtwk_suffix" runat="server" CssClass="form-control" ReadOnly="True" Enabled="False"></asp:TextBox>
</div>
I used form-inline class and I got the text boxes side by side. Find the attached sample output. Accept my answer if it works for you.
However there could be a better approach. Will post here if I found any.
<div class="form-group">
<asp:Label ID="lblwk_num" runat="server" AssociatedControlID="txtwk_num" Text="Work Order #" CssClass=""></asp:Label>
<asp:TextBox ID="txtwk_num" runat="server" ReadOnly="True" CssClass="form-control" Enabled="False"></asp:TextBox>
</div>
<asp:Label ID="lblwk_acct" runat="server" AssociatedControlID="txtwk_acct" Text="Account" ></asp:Label>
<div class="form-inline">
<div class="form-group">
<asp:TextBox ID="txtwk_acct" ReadOnly="True" Enabled="False" CssClass="form-control" runat="server" ></asp:TextBox>
</div>
<div class="form-group">
<asp:TextBox ID="txtwk_suffix" runat="server" CssClass="form-control" ReadOnly="True" Enabled="False"></asp:TextBox>
</div>
</div>

Is there a way to add a 3rd item template to a repeater

I have a repeater set up in Visual Studio to try and grab the latest 3 blog titles from the database and show the associated image along with the title, intro and a link.
However the parent div of each blog needs to have a different ID.
Currently I have the following code but it's not working because I've since found out you can't have an itemtemplate followed by an alternating item template followed by another item template.
I there any workaround to this?
<asp:Repeater runat="server" ID="repeaterNews1" DataSourceID="SQLDataNews1">
<ItemTemplate>
<div id="blog1">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image1" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div id="blog2">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image2" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</AlternatingItemTemplate>
<ItemTemplate>
<div id="blog3">
<div class="col-xs-12">
<asp:Image runat="server" ID="Image3" ImageUrl='<%# Eval("NewsStoryImage") %>'/>
<div class="blogContent">
<div class="container">
<h2>Our Blog</h2>
<p><asp:Label runat="server" ID="Label1" Text='<%# Eval("PageTitle") %>'></asp:Label></p>
<p><asp:Label runat="server" ID="Label2" Text='<%# Eval("Content1") %>'></asp:Label></p>
Read More
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
No, you cannot create a third template.
What you can do is make sure the ID's are still unique by using Container.DataItemIndex
<ItemTemplate>
<div id="blog<%# Container.DataItemIndex %>"></div>
</ItemTemplate>

Ajaxcontoltoolkit tab container not displaying alongisde modal popup extender

I'm using VS2010, C#, ASP.NET, I've inserted Ajax Control Toolkit Tab Container which works great, but when I insert a modal popup extender on another panel, tabs do not display! what is going wrong here? How can I have both on them as both are really cool effects
thanks
my tab container:
<cc1:TabContainer runat="server" ID="Tabs" CssClass="visoft__tab_xpie7"
ActiveTabIndex="2" Width="100%" Height="160px">
<cc1:TabPanel runat="server" ID="tab1" HeaderText="برنامه نویسی وب و اتوماسیون">
<HeaderTemplate>
<div >
<asp:Image ID="Image12" BorderStyle="None" runat="server" ImageUrl="~/Images/internet.png" /><br />
وب و اتوماسیون
</div>
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="divTab1" style="direction:rtl;">
</div>
</ContentTemplate>
<cc1:TabPanel runat="server" ID="tab2" HeaderText="تله متری" >
<HeaderTemplate>
<div >
<asp:Image ID="Image11" BorderStyle="None" runat="server" ImageUrl="~/Images/telemetry.png" /><br />
تله متری
</div>
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="divTab2" style="direction:rtl;">
</div>
<cc1:TabPanel runat="server" ID="tab3" HeaderText="">
<HeaderTemplate>
<div >
<asp:Image ID="Image10" BorderStyle="None" runat="server" ImageUrl="~/Images/mb.png" /><br />
موبایل، گرافیک، بازی
</div>
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="divTab3" style="direction:rtl;">
</div>
</ContentTemplate>
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="">
<HeaderTemplate>
<div >
<asp:Image ID="Image13" BorderStyle="None" runat="server" ImageUrl="~/Images/flash.png" /><br />
انیمیشن و فلش
</div>
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="divTab4" style="direction:rtl;">
</div>
</ContentTemplate>
my modal popup extender:
<asp:Panel ID="pnlNews1" runat="server" CssClass="modalPopup" >
<div style="height:100% ; overflow:auto; width: 100%; top:0px; bottom:0px">
<asp:Table ID="Table10" Height="32px" Width="100%" runat="server">
<asp:TableRow HorizontalAlign="Left">
<asp:TableCell>
<asp:ImageButton ID="btnClose1" ToolTip="بستن کادر" runat="server" ImageUrl="~/Images/close.png" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow HorizontalAlign="Right">
<asp:TableCell>
<asp:Label ID="lblTitle1" runat="server" Font-Names="Tahoma" Text="Label"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<div runat="server" id="divBody1">
</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
I don't know if this helps, but I had a very similar problem. I had some tabs working, then added a modalpopup extender and a panel, and suddendly my tabs dissappeared.
In my case, my modal popup panel's Visible property was set to "False" (which is not really necessary). Like this:
<asp:Panel ID="ModalPopupPanel" runat="server" CssClass="ModalPopupPanel" Visible="False">
When I deleted this property, the Tabs appeared. So it looks now like this:
<asp:Panel ID="ModalPopupPanel" runat="server" CssClass="ModalPopupPanel">
I know you are not setting this property, but maybe you can try something like this to find what is causing the problem?
Sorry I cannot be of any more help.

ASP Listview, ItemPlaceHolder problems

I've got a problem here with a div not being placed that way I'd like it to.
This is the ASP code I'm using:
<asp:ListView ID="categoriesListView" runat="server">
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" class="sub" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</ItemTemplate>
</asp:ListView>
I was expecting results like this:
<div class="main">
<div class="sub">
...
</div>
<div class="sub">
...
</div>
<div class="sub">
...
</div>
...
</div>
The result was one big div "main" containing everything, with no "sub" divs.
If I added the itemPlaceholder one level deeper, the same thing would happen, now with 1 "sub" div and everything pushed in there. How do I solve this?
Change it to look like this:
<LayoutTemplate>
<div class="main" runat="server">
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<EmptyDataTemplate>
<div class="main" runat="server">
<div class="sub" ID="itemPlaceholder" runat="server">
No data was returned.
</div>
</div>
</EmptyDataTemplate>
<ItemTemplate>
<div class="sub" >
<asp:Image AlternateText='<%# Eval("CategoryName") %>' ID="Image1" runat="server" ImageUrl='<%# Eval("CategoryImgUrl", "~/Images/{0}") %>' />
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("CategoryName") %>' />
</div>
</ItemTemplate>

Resources