asp menu showing differently in browsers - c#

I have a web application that has a menu bar on top of the page. This menu bar is showing fine in Internet explorer 9 however in chrome it is showing incorrectly. I don't really know how to make this css file a cross browser css file.
here is how it shows in IE.
and here is how it shows in chrome.
my css is as follows:
div.hideSkiplink
{
background-color: #796540;
width: 100%;
height: 56px;
margin: 0px 5px 20px 0px;
}
div.menu
{
padding: 1px 0px 1px 8px;
margin: 5px 0px 5px 0px;
}
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
and here is my page markup
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False"
IncludeStyleBlock="False" Orientation="Horizontal" BackColor="#F7F6F3" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#7C6F57" StaticSubMenuIndent="10px"
DataSourceID="SiteMapDataSource1" OnMenuItemDataBound="NavigationMenu_MenuItemDataBound">
</asp:Menu>
</div>
can somebody please help me?

try override default parameters of li paddings, li margins,hideskipling paddings

Try changing width: 100%; to something fix/constant. Alternatively, try reading this post http://fabenterprises.wordpress.com/2009/03/21/aspnet-menu-not-rendering-correctly-in-googles-chrome/

Related

Input CSS styles not working with runat server

I'm working on updating checkbox inputs to use the styles from the US Web Design Standards. However, I've ran into an issue when trying to update the checkboxes in pages still within our .NET app that have the runat="server" attribute.
Without the runat="server" attribute, the checkboxes render as in https://standards.usa.gov/components/form-controls/. With the runat="server" attribute, only the square outline renders and clicking on it does nothing - it doesn't change the background to blue, nor does it insert the checkmark svg.
Any help in understanding what is going on in order to make the styles work with runat="server" will be greatly appreciated.
This is the.NET code
<fieldset class="fieldsGroup standardFieldsGroup termsAndConditions"
runat="server" id="termsAndConditions">
<legend><span class="uppercase small">Terms & Conditions</span></legend>
<div class="formField fieldTypeCheckbox authorized">
<input type="checkbox" runat="server" id="idAuthorized"
name="authorized" class="authorized gs-input"/>
<label for="idAuthorized" class="gs-input">I am authorized by this
organization to update the information on their Page
</label>
<span class="validators">
<span id="idAuthorizedValidator" class="displayHidden">You must be
authorized to update the information on this organization's
Page Form</span>
</span>
</div>
<div class="formField fieldTypeCheckbox acceptTerms">
<input type="checkbox" runat="server" id="idAcceptTerms"
name="acceptTerms" class="acceptTerms gs-input" />
<label for="idAcceptTerms" class="gs-input">I agree to X's <a
id="aTermsAndConditions" href="https://x.org/terms-of-
use" target="_blank" class="black-link underline">Terms and
Conditions</a>
</label>
<span class="validators">
<span id="idAcceptTermsValidator" class="displayHidden">You must
agree to the X Terms and
Conditions
</span>
</span>
</div>
</fieldset>
The following is the CSS
input.gs-input {
//webkit-appearance: none;
//-moz-appearance: none;
//appearance: none;
border: 0.1rem solid #5b616b;
border-radius: 0;
box-sizing: border-box;
color: #212121;
display: block;
font-size: 1.7rem;
height: 4.4rem;
line-height: 1.3;
margin: 0.2em 0;
max-width: 46rem;
padding: 1rem 0.7em;
width: 100%;
}
label.gs-input {
position: relative;
left: 30px;
}
input.gs-input[type="checkbox"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
input.gs-input[type=checkbox] {
position: absolute;
left: -999em;
}
.lt-ie9 [type=checkbox], .lt-ie9
[type=radio] {
border: 0;
float: left;
margin: 0.4em 0.4em 0 0;
position: static;
width: auto;
}
[type=checkbox] + label.gs-input {
cursor: pointer;
font-weight: 400;
margin-bottom: 0.65em;
}
[type=checkbox] + label.gs-input::before {
background: #ffffff;
border-radius: 2px;
box-shadow: 0 0 0 1px #757575;
content: '\a0';
display: inline-block;
height: 2rem;
line-height: 2rem;
margin-right: 0.6em;
text-indent: 0.15em;
vertical-align: middle;
width: 2rem;
position: absolute;
left: -30px;
}
[type=checkbox]:checked + label.gs-input::before {
background-color: #0071bc;
box-shadow: 0 0 0 1px #0071bc;
}
[type=checkbox]:checked + label.gs-input::before {
background-image: url("../img/correct8.png");
background-image: url("../img/correct8.svg");
background-position: 50%;
background-repeat: no-repeat;
}
[type=checkbox]:disabled + label.gs-input {
color: #d6d7d9;
}
[type=checkbox]:focus + label.gs-input::before {
outline: 2px dotted #aeb0b5;
outline-offset: 3px;
}
[type=checkbox]:disabled + label.gs-input::before {
background: #f1f1f1;
box-shadow: 0 0 0 1px #aeb0b5;
cursor: not-allowed;
}
I did a bit of research based on #wazz comment above regarding setting ClientIdMode="Static" in the web.config file. I did not want to affect the entire application, however; just the specific inputs. I came across this blog
https://weblogs.asp.net/scottgu/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series
It mentioned that clientIdMode="Static" could be applied to individual elements. I modified the inputs as shown below and it solved my problem.
<input type="checkbox" clientIdMode="Static" runat="server" id="idAuthorized" name="authorized" class="authorized"/>
Sorry not really an answer; have to post here so i can add an image.
I'm not having trouble with this, but it did take a while to deal with the checkboxes and labels being off the page.
I'm sure you've covered this but just in case, make sure you're accessing the right element. The checkbox is left: -999em; and the label is -30. I took those off just so i could see them and got this (after creating the image and putting it in the right place).
I think it would be worth trying Static. Static will render the id you use on the page, AutoID "concatenates the ID values of each parent naming container with the ID value of the control."

How to resize a div element automatically so that the content fits

I need to do a lot of divs inside other divs, and I can't seem to understand what is the problem with my code, so the divs do not get the height of the divs below the- and everything is a mess!
my aspx code:
<div class="tabcontent">
<div class="tabcontent-inner">
<div class="tabcontent-inner-left grid_20">
</div>
<div class="tabcontent-inner-right grid_20">
</div>
</div>
</div>
my stylesheet css:
.tabcontent-inner {
width: inherit;
padding: 10px 10px 10px;
margin-top: 10px;
margin-bottom: 1px;
position: relative;
display: block;
}
.tabcontent-inner-left {
padding: 20px 20px;
border-left: solid 1px #ddd;
width: 45%;
float: left
}
.tabcontent-inner-right{
padding: 20px 20px;
border-right: solid 1px #ddd;
width: 45%;
float: right
}
Basically, I want the tabcontent-inner div to get the height of what is inside of it.
this is because on parent .tabcontent-inner you need to put overflow:auto property so that it will cover ups its children's height
you can find more suitable answer here How do you keep parents of floated elements from collapsing?
Add this code to Your CSS
.clearfix:after {
content: " "; /* Older browser do not support empty content */
visibility: hidden;
display: block;
height: 0;
clear: both;
}
and
change
<div class="tabcontent-inner">
to
<div class="tabcontent-inner clearfix">
Semi colons are missing in the css after
float : left
and
float : right

Iframe style code behind C#

I am trying to set each button to control the style of an iframe in c#.
The HTML code is as follows
style="border: 0px none; margin-left: -185px; height: 100%; margin-top: -533px; width: 100%;">
I have my C# code as
IFrame.Attributes.Add("style", "height: 100%, Margin-top:-533px, margin-left: -185px, width: 100%,");
The issue is that the C# is not acting out like the HTML, How do I amend the C# code to behave like the HTML ? Please Help.
Why d'ont you do like this below :
IFrame.Attributes["style"] = "border: 0px none; margin-left: -185px; height: 100%; margin-top: -533px; width: 100%;";

How do I center text on a web form?

This is what I have and it is not being centered. It's all the way to the left for some reason.
<div>
<asp:Label ID="eagleReplicationManagerLabel" runat="server" CssClass="eagleReplicationManagerLabel">
Eagle Replication Manager
</asp:Label>
</div>
css for it:
.eagleReplicationManagerLabel
{
position: fixed;
font-size: 30px;
color: #0000FF;
text-align: center;
}
It is actually working but you couldn't see the result because it is rendered as a span which takes the exact width of its content. So the text didn't have enough space to adjust.
Increasing the width in your css style will show you why
.eagleReplicationManagerLabel
{
position: fixed;
font-size: 30px;
color: #0000FF;
text-align: center;
width:500px;
}
The text-align: center; needs to be on the <div> that contains the label.
the text is centered but is is an inline element so it is only as wide as the text inside.
That is why you can't tell that it is centered.
Give it some width or make it block and you will see the centering.
.eagleReplicationManagerLabel
{
position: fixed;
font-size: 30px;
color: #0000FF;
text-align: center;
display:block
}
The problem here is that asp:Label is rendered as a span on html and span elements are, by default, styled with display:inline; as a result, your CSS class does nothing.
If you want to center the text in the DIV, set the text-align:center on the DIV or set display:block on .eagleReplicationManagerLabel
.eagleReplicationManagerLabel
{
position: fixed;
font-size: 30px;
color: #0000FF;
text-align: center;
display:block;
}
.center{
width:200px;
margin:auto;
}
.eagleReplicationManagerLabel
{
position: fixed;
font-size: 30px;
color: #0000FF;
text-align: center;
}
<div>
<div class="center">
<asp:Label Text="Eagle Replication Manager" ID="eagleReplicationManagerLabel1" runat="server" CssClass="eagleReplicationManagerLabel"></asp:Label>
</div>
</div>

asp.NET - Problems with Static Selected Style for a Selected Page on the menu

I am using asp.NET 4.0 with C# and have recently created a custom design for my local web application. I would like that when a page is selected, it has a different background colour (usually in plain html + css we just set a menu item as active). I tried using but it is not working, it stays the same colour as the others. Does any one has any experience with this?
Code in Site Master:
<h2>Dashboard</h2>
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Vertical" >
<StaticSelectedStyle CssClass="selectedMenu" />
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="View Submissions"/>
<asp:MenuItem NavigateUrl="~/Imports.aspx" Text="Import"/>
<asp:MenuItem NavigateUrl="~/Submission.aspx" Text="Insert Submission"/>
<asp:MenuItem NavigateUrl="~/Reports.aspx" Text="Reports"/>
<asp:MenuItem NavigateUrl="~/CurrencyMaintenance.aspx" Text="Currency Maintenance" />
<asp:MenuItem NavigateUrl="~/Remittance.aspx" Text="Remittance" />
</Items>
</asp:Menu>
CSS:
/* TAB MENU
----------------------------------------------------------*/
div.hideSkiplink
{
background-color:#3a4f63;
width:100%;
}
div.menu
{
padding: 4px 0px 4px 8px;
}
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
div.menu ul li a, div.menu ul li a:visited
{
background-color: #FFF; /*680840*/
border: 1px #4e667d solid;
height: 20px;
width: 175px;
color: #000; /*FFF*/
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
div.menu ul li a:hover
{
background-color: #680840;
color: #FFF;
text-decoration: none;
}
.selectedMenu
{
background-color: #680840 !important;
color: #FFF !important;
text-decoration: none !important;
}
div.menu ul li a:active
{
background-color: #680840;
color: #cfdbe6;
text-decoration: none;
}
This is what it looks like on Hover, I would like a similar effect on selected.
This seems to be a bug with the .NET menu. There is some information regarding this here. What you might want to do then is remove the staticSelectedStyle attribute and simply add this to your css:
.menu a.static.selected
{
background-color: #680840 !important;
color: #FFF !important;
text-decoration: none !important;
}
You might also have to add some code to your master's page load to determine which should be the selected item like this:
protected void Page_Load(object sender, EventArgs e)
{
string path = Request.AppRelativeCurrentExecutionFilePath;
foreach (MenuItem item in NavigationMenu.Items)
{
item.Selected = item.NavigateUrl.Equals(path, StringComparison.InvariantCultureIgnoreCase);
}
}

Categories