Positioning of controls within DIV - css

I have a set of controls that will show/hide when the user clicks a button. The controls consist of a grid, 2 labels, a dropdown, a text box and another button. I would like to position them as follows:
I have the grid positioned correctly but the dropdown and textbox controls are to the left but below the grid. The button is not centered.
How can I position the DIV with the controls to be positioned beside the grid and the button to display in the center but at the bottom of the main PANEL?
This is my makeup:
<asp:Button ID="btnShowMappingPanel" runat="server" Text="Update Value(s) in Multiple Mappings" Width="325px" />
<asp:Panel ID="pnlMultipleMappingControls" runat="server" Height="300px" Width="1000px" style="display:none;" BackColor="White" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px">
<div id="divMultiMapGrid" style="margin: 25px; width:45%">
<asp:GridView ID="msmgvMultiMappingSelection" runat="server" AllowPaging="True" PageSize="4" AllowSorting="True" AutoGenerateColumns="False" Caption="Select Multiple Mappings to Update"
CaptionAlign="Top" CssClass="grid" Visible="true">
<Columns>
<asp:TemplateField HeaderText="Select">
<EditItemTemplate>
<asp:CheckBox ID="msmgvCkBoxEditSelect" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="msmgvCkBoxSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mapping ID">
<ItemTemplate>
<asp:Label ID="msmgvLblMappingID" runat="server" Text='<%# Bind("EnrollmentMappingID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Schoology Course ID">
<ItemTemplate>
<asp:Label ID="msmgvLblSchoologyCourseID" runat="server" Text='<%# Bind("SchoologyCourseID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CE City Activity ID">
<ItemTemplate>
<asp:Label ID="msmgvLblCECityActivityID" runat="server" Text='<%# Bind("CECityActivityID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="divMultiMapControls" style="float:right; width:45%; padding:5px">
<div id="divMultiMapActiveCtrl" style="padding:10px">
<asp:Label ID="lblActive" runat="server" Text="Is Active: " CssClass="label"></asp:Label>
<asp:DropDownList ID="ddlActiveOptions" runat="server">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</div>
<div id="divMultiMapMaxEnrollCtrl" style="padding:10px">
<asp:Label ID="lblMaxEnrollment" runat="server" Text="Maximum Enrollment: " CssClass="label"></asp:Label>
<asp:TextBox ID="txtBoxMapEnroll" runat="server" Width="25%"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtBoxMapEnroll" runat="server"
ErrorMessage="Enter only integers." ValidationGroup="multiMapEditMappingValidation" ValidationExpression="^\d+$"
Display="Dynamic" CssClass="message-error">
</asp:RegularExpressionValidator>
</div>
</div>
<div id="divMultiMapUpdateBtn">
<asp:Button ID="btnUpdateSelectedMappings" runat="server" Text="Update Selected Mappings" Width="200px" CausesValidation="true"
ValidationGroup="multiMapEditMappingValidation" OnClick="btnUpdateSelectedMappings_Click" />
</div>
</asp:Panel>
AS REQUESTED this is the jsfiddle
<panel>
<div id="divMultiMapGrid" style="margin: 25px; width:45%">Grid is here</div>
<div id="divMultiMapControls" style="float:right; width:45%; padding:5px">Controls are here
<div id="divMultiMapActiveCtrl" style="padding:10px">Dropdown control</div>
<div id="divMultiMapMaxEnrollCtrl" style="padding:10px">text box control</div>
</div>
<div id="divMultiMapUpdateBtn">Button</div>

First of all Don't use inline CSS. It will be very tough to manage later.
Now for your question:
#divMultiMapGrid {
margin: 25px;
width: 45%;
float: left;
}
#divMultiMapControls {
float: right;
width: 45%;
padding: 5px;
}
#divMultiMapActiveCtrl {
padding: 10px;
}
#divMultiMapMaxEnrollCtrl {
padding: 10px;
}
#divMultiMapUpdateBtn {
clear: both;
margin: auto;
width: 104px; // adjust width based on button
}
If you are still interested only in inline style, then
<panel>
<div id="divMultiMapGrid" style="margin: 25px; width:45%;float: left;">Grid is here</div>
<div id="divMultiMapControls" style="float:right; width:45%; padding:5px">Controls are here
<div id="divMultiMapActiveCtrl" style="padding:10px">Dropdown control</div>
<div id="divMultiMapMaxEnrollCtrl" style="padding:10px">text box control</div>
</div>
<div id="divMultiMapUpdateBtn" style=" clear: both; margin: auto; width: 104px;">Button</div>
</panel>

Related

Dropdown list lost css and update panel trigger can't find control id inside gridview

Style of dropdown in css changes when the page loads. i have tried a number of ways to solve the problem. also i am not able to find dropdownlist id in Update Trigger... any suggestions to help me out...i am stuck at this..thank you in advance...
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True"
ForeColor="#333333" GridLines="None" ShowFooter="True" Width="855px">
<Columns>
<asp:BoundField DataField="SNo" HeaderText="S.N." ReadOnly="true" />
<asp:TemplateField Items Detail"
ControlStyle-Width="150px" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" ForeColor="Black" Height="35px" CssClass="chzn-select"
Style="width: 210px;" Font-Bold="false" AutoPostBack="true" OnSelectedIndexChanged="ddlItem_SelectedIndexChanged">
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalText" runat="server" Text="Total :"></asp:Label>
</FooterTemplate>
<ControlStyle Width="150px" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="" ControlStyle-Width="0px" Visible="true">
<ItemTemplate>
<asp:TextBox ID="txtMRP" runat="server" Enabled="false" Visible="true" BorderStyle="None"
BackColor="White" />
</ItemTemplate>
<ControlStyle Width="0px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="" ControlStyle-Width="0px" Visible="true">
<ItemTemplate>
<asp:TextBox ID="txtAmount" runat="server" Enabled="false" Visible="true" BorderStyle="None"
BackColor="White" />
</ItemTemplate>
<ControlStyle Width="0px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlItem" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<br />
<div style="margin-left: 50px; margin-top: 10px">
</div>
<br />
<asp:Button ID="btnAddSalesOrder" runat="server" Text="Send Inquiry" OnClick="btnAddSalesOrder_Click"
Style="margin-left: 30px; color: White; background-color: #088FCA;" OnClientClick="myClosure();"
class="btn btn-info" />
<asp:Button ID="btnPlaceOrder" runat="server" OnClick="btnPlaceOrder_Click" Text="Place Order"
Style="margin-left: 30px; color: White; background-color: #088FCA;" OnClientClick="myClosure();"
class="btn btn-info" />
<asp:UpdateProgress ID="UpdtProgress" DisplayAfter="1" runat="server" EnableViewState="False">
<ProgressTemplate>
<div style="top: 0px; height: 120%; background-color: White; opacity: 0.75; filter: alpha(opacity=75);
vertical-align: middle; left: 0px; z-index: 999999; width: 120%; position: absolute;
text-align: center;">
<img src="Images/loader.gif">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<script type="text/javascript">
$('.chzn-select').select2({
no_results_text: 'Oops, nothing found!',
allowClear: true,
maximumSelectionSize: 1,
width: '130px;'
});

Css footer on media print

I am trying to print my web page as a report. I have done css for screen and different for print mode to be able when i pres CTRL+P to print it.
My problem is when I have 2 pages the footer doesn't move to go on page 2 bottom.
How I can do this?
css:
#footer{
position:absolute;
bottom:0%;
width:100%;
height:60px; /* Height of the footer */
border-bottom: 1px solid black;
border-top: 1px solid black;
}
#total{
bottom:85%;
float:right;
text-align:right;
position:absolute;
margin-left:62%;
margin-bottom:2%;
border-left: 1px solid black;
border-top: 1px solid black;
border-right: 1px solid black;
}
#custsign{
margin-left:60%;
margin-top:-10%;
padding-top:3%;
}
#compsign{
padding-top:0.3%;
margin-left:80%;
margin-top:-2.4%;
}
/*#grid{
padding-bottom:30%;
}*/
aspx:
<div id="footer">
<div id="total">
<asp:Label ID="SubLabel" runat="server" Text="Sub Total: " ></asp:Label>
<asp:Label ID="SubText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="DiscLabel" runat="server" Text="Discount: " ></asp:Label>
<asp:Label ID="DiscText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="VatLabel" runat="server" Text="V.A.T.: " ></asp:Label>
<asp:Label ID="VatText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="TravelLabel" runat="server" Text="Travel Exp.: " ></asp:Label>
<asp:Label ID="TravelText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="CurrencyLabel" runat="server" Text="" ></asp:Label>
<asp:Label ID="TotalLabel" runat="server" Text="Amount Due: " Font-Bold="true"></asp:Label>
<asp:Label ID="TotalText" runat="server" Text="" ></asp:Label>
<br />
</div>
<asp:Label ID="ItemsLabel" runat="server" Text="Total No.Items: " ></asp:Label>
<asp:Label ID="ItemsText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="PrevBalanceLabel" runat="server" Text="Prev Balance: " ></asp:Label>
<asp:Label ID="PrevBalanceText" runat="server" Text="" ></asp:Label>
<br />
<asp:Label ID="NewBalanceLabel" runat="server" Text="New Balance: " ></asp:Label>
<asp:Label ID="NewBalanceText" runat="server" Text="" ></asp:Label>
<div id="custsign">
<asp:Label ID="CustomerSignLabel" runat="server" Text="Customer" Font-Bold="true"></asp:Label>
</div>
<div id="compsign">
<asp:Label ID="CompanieSignLabel" runat="server" Text="Companie Ltd" Font-Bold="true"></asp:Label>
</div>
</div>
example files:
UPDATE with position:fixed
How about to use the code of this example?
Make an Editable/Printable HTML Invoice
You can change position: absolute to position: fixed on your #footer selector.
<style>
#media screen {
#footer {
position: absolute;
/*Other styles...*/
}
}
#media print {
#footer {
position: fixed;
bottom: 0;
/*Other styles...*/
}
}
</style>
This change will make your #footer repeat itself on every page.

asp.NET CSS Issue on Post Back

We are currently developing an asp.NET 4.0 Web Forms application. In a particular screen we attempted to create a grid view with a fixed header and footer. We got this working how we wanted, but then we realised that when we click a button which issues a partial post back (triggers required field validators for example) the fixed header disappears.
Any ideas why this is happening?
Code as follows:
CSS (relevant parts):
.tableStyle
{
}
.tableStyle th
{
text-align: left !important;
padding: 2px 5px !important;
font-weight: bold;
}
.tableStyle td
{
padding: 1px 5px !important;
text-align: left;
}
.container
{
overflow-y: scroll;
overflow-x: hidden;
height: 500px;
}
.container table tbody
{
overflow-x: hidden;
}
/* Creates a Scrollable Div */
.GridViewContainer
{
overflow: auto;
}
.freezeHeader
{
position: absolute;
background-color: White;
font-weight: bold;
margin-top: -40px;
padding-bottom: 5px;
z-index: 99;
}
.freezeFooter
{
position: absolute;
background-color: White;
top: 530px;
padding-bottom: 20px;
z-index: 95;
}
.paddingTop
{
margin-top: 40px;
}
ASPX Page (Grid View Part):
<fieldset>
<legend>Products Mapping Table (EXT_CFG_PDT_MAP)</legend>
<div id="grdWithScroll" class="container">
<asp:GridView
ID="ProductsMappingTableGridView"
AutoGenerateColumns="false"
runat="server"
OnRowCancelingEdit="ProductsMappingTableGridView_RowCancelingEdit"
OnRowEditing="ProductsMappingTableGridView_RowEditing"
OnRowUpdating="ProductsMappingTableGridView_RowUpdating"
ShowFooter="true"
OnRowCommand="ProductsMappingTableGridView_RowCommand"
CssClass="tableStyle paddingTop"
HeaderStyle-CssClass="freezeHeader"
FooterStyle-CssClass="freezeFooter">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="editButton" Text="Edit" CausesValidation="false" CommandName="Edit" runat="server" Enabled='<%# Session["ProductsMappingsWriteAccess"] %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="updateButton" Text="Update" CommandName="Update" runat="server" ValidationGroup="Edit"/>
<asp:Button ID="cancelButton" Text="Cancel" CausesValidation="false" CommandName="Cancel" runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="insertButton" Text="Insert" CommandName="Insert" runat="server" ValidationGroup="Insert" Enabled='<%# Session["ProductsMappingsWriteAccess"] %>'/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Product Mapping ID</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="mptIdLabel" runat="server" Text='<%# Eval("MPT_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Source Key</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="srcKeyLabel" runat="server" Text='<%# Eval("SRC_KEY") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList AutoPostBack="false" ID="srcKeyListEdit" runat="server" Width="95px" OnLoad="SrcKeyListInitalization" >
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList AutoPostBack="false" ID="srcKeyListInsert" runat="server" Width="95px" OnLoad="SrcKeyListInitalization"
Visible='<%# Session["ProductsMappingsWriteAccess"] %>'>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Product Key - Source</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="pdtKeySrcLabel" runat="server" Text='<%# Eval("PDT_KEY_SRC") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="pdtKeySrcTextBoxEdit" runat="server" Text='<%# Eval("PDT_SRC") %>'
MaxLength="32"></asp:TextBox>
<br />
<asp:RequiredFieldValidator runat="server" ID="pdtKeySrcTextBoxEditRequiredFieldValidator"
ControlToValidate="pdtKeySrcTextBoxEdit" ValidationGroup="Edit" ForeColor="Red"
ErrorMessage="PDT_KEY_SRC is required"></asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="pdtKeySrcTextBoxInsert" runat="server" Text='<%# Eval("KEY_SRC") %>'
MaxLength="32" Visible='<%# Session["ProductsMappingsWriteAccess"] %>'></asp:TextBox>
<br />
<asp:RequiredFieldValidator runat="server" ID="pdtKeySrcTextBoxInsertRequiredFieldValidator"
ControlToValidate="pdtKeySrcTextBoxInsert" ValidationGroup="Insert" ForeColor="Red"
ErrorMessage="PDT_KEY_SRC is required"></asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</fieldset>
Update 1: I would like to point out that this appears not to have been affected on IE 8 but it was affected when I used IE 10.
A hotfix is available for the ASP.NET browser definition files in the Microsoft .NET
please refer http://support.microsoft.com/kb/2600088 for .NET 4.0
Refer http://support.microsoft.com/kb/2608565 for .Net 3.5

Divs not working as expected

I am trying to create the rows of controls. Basically it is for filtering a search. There are six controls in each row, 3 labels and 3 dropdownlists/textboxes. I have a div which creates rows and the first row turns out great but the rest is really weird.
The markup is the following
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterDepartmentLabel" AssociatedControlID="FilterDepartment" runat="server" Text="Department" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterDepartment" runat="server" CssClass="aThirdInput" />
<asp:Label ID="FilterCardStatusLabel" AssociatedControlID="FilterCardStatus" runat="server" Text="Status" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardStatus" runat="server" CssClass="aThirdInput" />
<asp:Label ID="FilterCardBehaviorLabel" AssociatedControlID="FilterCardBehavior" runat="server" Text="Behavior" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardBehavior" runat="server" CssClass="aThirdInput" />
</div>
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterCarPlateLabel" AssociatedControlID="FilterCarPlate" runat="server" Text="Car Plate" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterCarPlate" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterCardNoLabel" AssociatedControlID="FilterCardNo" runat="server" Text="Car No" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterCardNo" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterRuleSetCodeLabel" AssociatedControlID="FilterRuleSetCode" runat="server" Text="Rule Set" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterRuleSetCode" runat="server" CssClass="aThirdInput" />
</div>
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterDriverLastNameLabel" AssociatedControlID="FilterDriverLastName" runat="server" Text="Driver Lastname" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterDriverLastName" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterCardTypeLabel" AssociatedControlID="FilterCardType" runat="server" Text="Type" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardType" runat="server" CssClass="aThirdInput" />
</div>
And here is the css
.fullRow
{
width: 100%;
display:block;
}
.aThirdLabel
{
width: 15%;
float: left;
font-size:small;
height: 22px;
}
.aThirdInput
{
width: 15%;
float: left;
}
Actually, even though this looks good in design view of VS2010, when its loaded in the browser, its a mess.
Thanks
EDIT: The answer is in the comment huMpty duMpty made.
Add <div style="clear:both;"></div> after each row.

How to align objects vertically in ASP.NET?

I have been messing around with asp.net for awhile now and always have issues aligning objects with various heights on the same row. For example, in this case, I have a search label, a text field, then a image button. What is the "proper way" to get these three items to align properly?
My existing code:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel VerticalAlign="Center" runat="server">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large"
Height="30px" style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px"
ImageUrl="~/Images/SearchButton.PNG" style="margin-left: 18px; margin-top: 0px"
Width="95px" />
</asp:Panel>
</asp:Content>
The easiest is using CSS or tables. I put a div around with a height and vertical align to the top. CSS Reference
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel ID="Panel1" VerticalAlign="Center" runat="server">
<div style="height: 40px; vertical-align: top">
<div style="padding-top: 10px; float:left;">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
</div>
<div style="padding-top: 5px; float:left;">
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large" Height="30px"
Style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
</div>
<div style="padding-top: 5px; float:left;">
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px" ImageUrl="~/Images/SearchButton.PNG"
Style="margin-left: 18px; margin-top: 0px" Width="95px" />
</div>
</div>
</asp:Panel>
</asp:Content>
i had the same problem and i think that using a table or a div only to align the Textbox it's excessive.
I solved simply:
<asp:TextBox ID="TextBox2" runat="server" Width="60px"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/imatges/imgNou.png"
CssClass="style3" ImageAlign="AbsBottom" />
And adding the margin-top in Design view, the IDE added:
.style3
{
margin-top: 6px;
}

Resources