.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Asad Ali
Fauzul Azmi
Post New Web Links

Hover-Style for single elements of a new control

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


I've a UserConrol, lets say ButtonX with several parameters like color, text and border. This parameters are passed to different elements of my control, e.g., the text to an asp:Label and the border to the style attribute of an enclosing DIV. No I want to pass some parameter to the hover and active state of some inner control elements (e.g., the DIV). I know how to set every CSS style parameter of an asp:Label or DIV - but how can I set the hover parameters?

I can not write an external CSS class like

.button1:hover { ... } and assign this, because the color is assigned dynamically via the UserControl like <xy:ButtonX id=".." hoverColor="..." runat="server"/>

Thus, how can I change the hover parameters in my C# code behind dynamically?


Many Thanks


View Complete Post

More Related Resource Links

ASP.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

How to use CSS to style just one of the columns in a GridView control

<asp:Boundfield Datafield="City" Headertext="City" sortexpression="City" CONTROLSTYLE-CSSCLASS="allcaps"/> I'm trying to use the CSS property "text transform" to make just one specific GridView column "all caps" (see above), but it has no effect. It only works when I place the reference to the class ".allcaps"  in the main tag at the top of the GridView control---but that makes all columns "all caps". How can I style just one column using CSS?   Thanks.  

UPDATED: AJAX FAQ? And: How to Style the AJAX tab control's tabs: complete information

UPDATE April 08, 2009: for the latest version of this post, with up-to-date info on styling the Tab control, see my just updated Blog post -- the info below is somewhat outdated and does not have some additional details I have added to the Blog post.   First of all, I would like to suggest that the AJAX section of the ASP.NET forums have its own FAQ section. I was going to post this in the general ASP.NET FAQ, but it didn't really fit, and there was no AJAX FAQ, so I'm posting it here. Next: I have been looking for details on how to style the Tabs in the AJAX Toolkit's Tab control for over a week now. I have found information that is misleading, incomplete, outdated, and just plain wrong. And nowhere have I come across all the information needed to make it work in one place. So, I am posting this here. I hope that an AJAX FAQ can be created, and this post moved there.   I am including some background information, about the difficulties people are having in finding information on styling the tabs, first; after that I will include the complete instructions for styling the tabs. First: the information on the documentation page for styling the tabs is misleading at best, as well as incomplete. The docs tell you that you can simply add your styles to your project as CSS, and neglect to tell you that you must add a "CssClass" attribu

How to reference a elements of one control from other


Can someone explain how user controls can communicate with each other within an asp.net application. I am facing many obstacles at the moment regarding this problem. For example, is it possible to set the visible property of a panel on one user control based on what happens in another?

Another example would be: Can I set the text of a label in one control to be the value of some other property from another control's class like.... Me.PreContentColumn.ColumnID = LocalProduct.PreContentColumnId.

Please let me know if this sounds confusing...

Style Trigger or or Control Template to swap GradientStops


I have an Ellipse that is part of a UserControl.

     <GradientStop Color="{Binding Path=CommandBg, FallbackValue=DarkBlue}" Offset="{Binding Path=CommandGradient,FallbackValue=2}" />
     <GradientStop Color="White" Offset="0" />

The Grid Has two events:


And on the mouse down event I want to swap the GradientStop properties, and then on MouseUp, swap them back.

How can this be accomplised in XAML?



Base Style with named visual elements


Hy everybody,I am struggling with a problem. I want to create a base look for my application buttons. This is the base style that I want to apply:


    <Style TargetType="{x:Type common:NumericIncDec}">
      <Setter Property="Control.Template">
            <Border Width="115

I need to Group Elements in Nested Repeater Control



User Group Management
User Groups Add  Delete   Edit  View  Activate/Deactivate  Export
User Management

default style for control

Hi all , I have a problem when I use button in some code base , I found some guys already defined lots of style for the button and buttonbase , but I want to use the default style in WPF , can I prevent the button inherit the style from custom , only use the WPF ?

How to save a multiple user control to a few single record text?

I have a list with people pecker control that admits multiple users.
I like to have another list with one record for each user in the control that loaded before.
Is there any way in InfoPath or in a workflow to use something like FOR EACH to take one by one user in a control and write/update records after that?
Thank in advance

CalendarExtender loses style when placed inside a web user control.


I'm losing the format of the calendarExtender when I include it within a web user control. The code below is included within a user control. The user control is then dropped onto a page.

<asp:UpdatePanel id="UpdatePanel1" runat="server">
        <asp:GridView ID="GridView1" runat="server"
            AllowPaging="True" AllowSorting="True"
            EmptyDataText="There are no data records to display.">
                <asp:TemplateField HeaderText="Target_Date" SortExpression="Target_Date">

Is is possible to pre-compile a single control or a page ...



I am working on an asp.net web site project with a large codebase.  Publishing the site takes about 30 minutes. Since I have to do this twice a day, this takes up too much of my time. Is there a way to publish only changed pages or controls. Visual studio does give an option to compile a single page or control by right clicking on it and selecting "build page". 

Is it possible to publish a single page, maybe through command line.


Can you have control over the names of HTML elements?



I was just wondering, is it possible to have control over the name of an HTML element that's bound to a property of a viewmodel? For example, if I had a viewmodel with a property called ProductDescription, is it possible to have a text input in the view with the name "desc" instead of "ProductDescription" and somehow tell MVC that "desc" binds to ProductDescription?

Not a big issue, but it would be nice to have control over how my HTML elements are named.


Menu Control: Swap Image on Hover Over


hi, im working on a menu control with a horizontal orientation and 4 gifs for the individual menu items that are separated by about 10px. what im trying to do is to swap these images out on a mouse hover over. i know the menu control doesn't support an image-swap-on-hover functionality, so im looking for a work around. someone over at the stackoverflow website suggested i try this, but it didn't work for me.

<asp:Menu ID="menu" runat="server" Orientation="Horizontal" StaticMenuItemStyle-CssClass="staticMenu" StaticHoverStyle-CssClass="hoverMenu">
<asp:MenuItem NavigateUrl="~/benefits.aspx" />

don't apply static hover style to siteMapNode that has an empty url property



I was wondering if there is any way to not apply the static hover effect to asp:menu items where their corresponding sitemapnodes don't have a url specified?

It sounds a little confusing so I thought I'd add snippets of what I'm trying to do:

I have a sitemap file with 3 levels:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/default.aspx" title="SOME TITLE"  description="">
    <siteMapNode url="" title="Admin"  description="" roles="Admin">
      <siteMapNode url="~/admin/userMgmt.aspx" title="User Mgmt"  description="" />
      <siteMapNode url="~/admin/roleMgmt.aspx" title="Role Mgmt"  description="" />
    <siteMapNode url="" title="Users"  description="" roles="User">
      <siteMapNode url="~/Users/MyAssignments.aspx" title="My Assignments"  description="" />

I then have my sit

Default style on control?


What is the proper way to set up default styles for a Custom Control Library?

I wanted to have the control and style in the same library but it was not calling the OnApplyTemplate().
Company.Framework -> WPF -> Controls -> MyControl -> MyControl.cs
Company.Framework -> WPF -> Controls -> MyControl -> MyControlStyle.xaml

I realized I needed a Generic.xaml.  When I had it set up this way, my modules would throw errors when trying to load.
Company.Framework -> WPF -> Controls -> MyControl -> MyControl.cs
Company.Framework -> WPF -> Controls -> MyControl -> MyControlStyle.xaml
Company.Framework ->Themes -> Generic.xaml
Company.Shell ->App.xaml

This is currently how I have it set up. It works, but I want the default style back with the control.
Company.Framework -> WPF -> Controls -> MyControl -> MyControl.cs
Company.Shell -> DefaultSkin -> Resources -> MyControlStyle.xaml
Company.Shell -> DefaultSkin -> Resources.xaml


Activate Form/Process menustrip or toolstrip control with Single Click


I am trying to make my form process the form activate and the ToolStrip or MenuStrip selection with a single click.  Currently, if a form does not have focus and you mouse over the ToolStrip or MenuStrip options they highlight like you can click them.  Only you have to click once to activate the form and again to activate the option you are over.  Does anyone know of a way to do this in a single click?


I have found this as a solution http://www.codeproject.com/KB/menus/UpgradeToMenuStrip.aspx?msg=2615988.  It does work however; it breaks the C++ form editor.  Is there another way to do this?


Thank You

How to change style for a control contained in a ControlTemplate


How to change style for a control contained in a ControlTemplate


I have defined a ControlTemplate as shown below (pretty much just a combobox kind of control).

I hoped that I would be able to change the control template for the dropdown button where used on the form by overwriting the DropDownButtonStyle like this, but it doesn’t work.


How can I overwrite the style for a control contained in a control template? (other than exposing the control as a property on the custom control)


UserControl.Resources – this should give me the brown button style

<Style x:Key="DropDownButtonStyle

Users Add  Delete EditViewActivate/DeactivateExport
Roles Add  Delete EditViewActivate/DeactivateExport
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend