dropdown ListItem background color change - asp.net

I am trying to make background color of by DropDown as transparent even for Listitem.
<asp:Label ID="Label1" runat="server" Text="Language : " style="color:white;padding:0 2px 0 2px;background-color: transparent !important;" />
<asp:DropDownList ID="ddlLanguages" runat="server" AutoPostBack="true" style="color:black;background-color: transparent !important;" >
<asp:ListItem style="background-color:transparent" Text="English" Value="en-us" />
<asp:ListItem style="background-color:transparent" Text="French" Value="fr" />
</asp:DropDownList><span style="color: white;;padding:0 2px 0 2px;"> | </span>
but it does not work even added css in my main CSS file still not work
select.tt-dropdown-menu {
background-color: transparent !important;
}
select.tt-dropdown-menu .tt-suggestions .tt-suggestion {
cursor: pointer;
border-bottom: 1px solid #000;
}
not sure why not its working. Any Suggestions !!

Actually, changing the background color to transparent doesn't have any effect at all. That because the select option container has some attributes that are defined by the browser in the first place and the operating system secondly. This means if you change the background color of the ListItem to transparent, the container's color is white and you won't be able to find the difference. Except transparent, you can change the color of the odd, even elements, by using that js/jquery script:
window.onload = function () {
$("#<%=ddlLanguages.ClientID%> option:odd").css("background-color", "red");
$("#<%=ddlLanguages.ClientID%> option:even").css("background-color", "blue");
}
Which can be achieved by css, but I see jquery a more stable choice for implementation in web forms

Related

remove background from radcombo box

I am using radcombobox to display data, now I am not using any css style for the radcombox, but it still has gray color background.
I want to remove that color.
Below is my rad combobox code :
<telerik:RadComboBox ID="RadCountry" runat="server" CssClass="rcbInput rcbEmptyMessage"
AutoPostBack="False" EmptyMessage="Select a Customer" EnableAutomaticLoadOnDemand="True"
ItemsPerRequest="10" ShowMoreResultsBox="True" EnableVirtualScrolling="True" Filter="Contains" DataTextField="Contact_First_Name"
Font-Names="Arial" Font-Size="11px" ShowToggleImage="false">
</telerik:RadComboBox>
I am also attaching the output of the given code.
i solve this by using below css
<style type="text/css">
div.CustomCssClass .rcbInputCell INPUT.rcbInput {
color: black;
height: 1px;
padding-top: 10px;
}
</style>
Use browser debugger and goto to Inspect Element, find which class / element is the reason for background. Then overwrite css to background:none!important for that element / css rule.

Textbox border color for field missing using CSS

I have web page with multiple text boxes, I have added Ajax-ValidateCalloutExtender to validate text boxes and it is working fine.
I have added CCS to highlight text boxes to be "Red" for field missing but it does not highlight the text box border to be "Red" .
See my coding below,
<td>
<asp:TextBox ID="txtPlanName" runat="server" Width="250px" BorderColor="#669999"
BorderStyle="Solid" BorderWidth="1px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your Plan Name" Display="None" SetFocusOnError="true" ControlToValidate="txtPlanName" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" TargetControlID="RequiredFieldValidator1" Enabled="true" runat="server" HighlightCssClass="tkpdna_req_field_highlight" ></asp:ValidatorCalloutExtender>
</td>
CSS
.tkpdna_req_field_highlight {
border-color:Red;
border-style:solid;
}
you're missing border-width (which is 0 as default, this is why you don't see it).
do it as following:
.tkpdna_req_field_highlight {
border:solid 1px red !important;
}
adding !important to force override of previous style values.
hope that helps
Try the !important override:
.tkpdna_req_field_highlight {
border: 1px solid red !important;
}
Next to that, make sure that the textarea is rendered properly and the class attribute including the classname is added to the textbox like so:
<textarea class="tkpdna_req_field_highlight" ... ></textarea>

How to change the background color of telerik radrotator selected item

I am using radrotator in my application , how can i change the border color or color of the rotator selected item from asp.net c# code behind , can i expect some help on this.
You can change the border of the RadRotator control and its items via additional CSS classes:
The internal CSS class rrClipRegion can be overridden in order to set a new color for the rotator control's border:
.rrClipRegion
{
border: 1px solid green !important;
}
You can set a default border color for the RadRotator's items via CSS and then you can change it from the code behind by defining a CSS class with new border color, as shown below:
The RadRotator markup:
<telerik:RadRotator ID="RadRotator1" runat="server" FrameDuration="3000" ScrollDirection="Left"
Height="123px" ItemHeight="113px" Width="180px" ItemWidth="152px" Skin="Default"
RotatorType="Buttons" OnItemClick="RadRotator1_ItemClick">
<ItemTemplate>
<div>
<img src="....." alt="" />
</div>
</ItemTemplate>
</telerik:RadRotator>
The styles, needed for applying the borders:
<style type="text/css">
.rrItem
{
margin: 4px;
}
.rrItem img
{
border: 1px solid grey;
}
.cssSelectedItem img
{
border: 1px solid red;
}
</style>
Changing the item's border color from the code-behind:
protected void RadRotator1_ItemClick(object sender, RadRotatorEventArgs e)
{
RadRotatorItem item = (RadRotatorItem)e.Item;
item.CssClass = "cssSelectedItem";
RadRotator1.InitialItemIndex = e.Item.Index;
}
Note that I have set the InitialItemIndex property of the rotator control in order to preserve the current item through postback. Also, the example is designed for images with size 150x113, so if different sizes are being utilized you should change the properties Width, Height, ItemWidth, ItemHeight accordingly.

How do i remove box surrounding the image while using hyperlink?

A rectange is appearing outside the link which i dont want. How do u remove it.
No Image
<a href="~/Web Pages/Home.aspx" runat="server">
<img src="<%= ResolveUrl("~/Images/TestToday.png") %>" alt="No image" width="200" height="200"/>
</a>
border = "0"
that will do the trick
or in css:
img {
border:0px;
}
You need this CSS rule:
a img {border: none; }
Put this in your css:
:link img { border: 0; }
You probably see the anchor tags border.
Try adding BORDER="0" to your a tag. Or set border to none in your stylesheet
Are you talking about the dotted outline that appears when clicking a link?
Try
a:active
{
outline: none;
}
this removes the outline when clicking, but not when entering the link using the keyboard (which is when it's really needed).
try this use ForeColor="White"
<asp:hyperlink runat="server" ImageUrl ="Images/back.jpg" D="hlBack" ForeColor="White" >
</asp:hyperlink>

Using the jquery layout within an ASP.NET UpdatePanel

I have a ASP.NET site with nested Masterpages that utilize the .layout() function in jquery.layout.js.
All of the pages display beautifully resizing dynamically, rendering a resizer bar, and vertically scrolling areas. i.e. all of the layout functionality is working.
However I would like to eliminate the "flicker" I am getting on PostBack, so wanted to introduce an ASP:UpdatePanel.
I tried to surround everything within the form on the root Master page with an ASP:UpdatePanel, at which point all of my beautiful formating disappeared, and my pages look a mess. I seem to lose my resizer bar completely and my ui-layout-center now appears
at the bottom of the screen.
My master page resembles the following:
<body id="body">
<form id="BaseForm" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="ui-layout-north banner">
etc etc
'
'
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
I am using the following script to format my pages:
$(document).ready(function() {
var myLayout;
// myLayout = $('body').layout(); -- syntax with No Options
myLayout = $('#body').layout({
// enable showOverflow on north-pane so popups will overlap other panes
north__showOverflowOnHover: false
// some resizing/toggling settings
, north__spacing_open: 0
// no resizer-bar when open (zero height)
, north__spacing_closed: 0
// big resizer-bar when open (zero height)
, south__spacing_open: 0
, south__spacing_closed: 0
, east__spacing_open: 0
, east__spacing_closed: 0
, south__minSize: 40
, east__maxSize: 10
, north__minSize: 80
, west__minSize: 300
, west__maxSize: 600
});
});
The styles are as follows:
.ui-layout-pane { /* all 'panes' */
background: #FFF;
border: 0px solid #fff;
padding: 10px;
overflow: auto;
}
.ui-layout-north {*overflow:hidden;}
.ui-layout-south {padding:0px;}
.ui-layout-east {padding:0px;}
.ui-layout-west {
margin-bottom:10px !important;
margin-left:10px !important;
border-right: solid 10px transparent;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
background:#f2f2f3;
border-left:1px solid red;
border-bottom:1px solid red;
}
.ui-layout-center {
padding: 0px !important;
margin-right:10px !important;
margin-bottom:10px !important;
background:#f2f2f3;
border-right:1px solid red;
border-bottom:1px solid red;
}
.ui-layout-resizer { /* all 'resizer-bars' */
background: #fff;
}
.ui-layout-resizer-west {
background:#efefef;
border-bottom:1px solid red;
}
.ui-layout-toggler { /* all 'toggler-buttons' */
background: #111;
}
I have tried various ways of registering my script
- Registering this script using ClientScript.RegisterClientScriptInclude
- using pageload()
- using Sys.WebForms.PageRequestManager.getInstance().add_endRequest
I am sure that the script is running ok as I have added alert("Please work!"); and the alert displays. So something else is interferring with the rendering.
Has anyone any ideas?
A quick suggestion off the top of my head:
If your layout is being broken by the additional div tag that the update panel renders - can you make it just replace the top level div in your layout, instead of surrounding it?
<asp:UpdatePanel ID="updPanel" runat="server"
UpdateMode="Conditional" CssClass=""ui-layout-north banner">
<ContentTemplate>
etc etc
'
'
</ContentTemplate>
</asp:UpdatePanel>
Try registering your javascript file in your scriptmanager.
For example:
<asp:ScriptManager ID="SMgr" runat="server">
<Scripts>
<asp:ScriptReference path="MyScript.js" />
</Scripts>
</asp:ScriptManager>
the fix is simple, you just have to update the "jquery.layout.js" defaults to allow for nested content.
first add a parent container, this can sit just inside the update panel, see:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<div id="ui-wrapper">
remember the closer:
</div>
</ContentTemplate>
</asp:UpdatePanel>
then update the script parameters (You can do this in the "myLayout" bit):
, north__paneSelector: "#ui-wrapper .ui-layout-north"
, south__paneSelector: "#ui-wrapper .ui-layout-south"
, east__paneSelector: "#ui-wrapper .ui-layout-east"
, west__paneSelector: "#ui-wrapper .ui-layout-west"
, center__paneSelector: "#ui-wrapper .ui-layout-center"
Hope this helps
Chris

Resources