473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I change the background color of a dynamic linkbutton inside of a repeater?

Hi All,

I am brand new (like 2 weeks) to ASP.NET and VB.
I have a series of linkbuttons that are generated dynamically inside a repeater.
I need the background color of the selected linkButton to change and remain a new color when clicked. I thought that the ItemCommand property of the repeater would do the trick, but it doesn't.

Here is the code for the repeater:

Expand|Select|Wrap|Line Numbers
  1.     <asp:Repeater ID="rptModuleMenuList" runat="server" DataSourceID="srcModuleItemList" OnItemCommand="rptModuleMenuList_ItemCommand" OnItemDataBound="rptModuleMenuList_DataBound">
  2.         <HeaderTemplate>
  3.             <div class="moduleMenuClass">
  4.         </HeaderTemplate>
  5.         <ItemTemplate>
  6.                 <asp:LinkButton runat="server" ID="modMenuButton1" CommandName="loadSubMenu" CommandArgument='<%#Eval("menu_item_id") %>' CssClass="taskMan"><%#Eval("menu_item_name") %></asp:LinkButton>
  7.         </ItemTemplate>
  8.         <FooterTemplate>
  9.             </div>
  10.         </FooterTemplate>
  11.     </asp:Repeater>
Here is the Code Behind:


Expand|Select|Wrap|Line Numbers
  1.     Protected Sub rptModuleMenuList_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptModuleMenuList.ItemCommand
  2.            Dim myButton As LinkButton
  3.            myButton = Me.FindControl(e.Item.ClientID.ToString())
  4.            myButton.BackColor = Drawing.Color.DimGray
  5.     End Sub

I have been hunting, reading, and reworking for a couple of hours now and I am completely confused. Any help would be greatly appreciated. Thanks!

Mike
Mar 2 '10 #1
2 5817
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Mar 2 '10 #2
Frinavale
9,735 Expert Mod 8TB
I think that your CssClass for your LinkButton is overwriting what you are changing in code. Try changing the CssClass instead of setting the ForeColor.

-Frinny
Mar 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Gary | last post by:
I have a table with a form consisting of several checkboxes and I'm wondering if its possible to change the table row background color on mouseover or hover and make it stay that color when the...
7
by: John Baker | last post by:
Hi: I imagine there are hundreds of responses to this question, but i cant find any on the site using a search. How do you change the background color of buttons? I know there must be an easy...
4
by: Georges Heinesch | last post by:
Hi. I have a form defined as datasheet view. Can I change the background color of the individual fields (colums) separately (or all together)? If yes, how? TIA --
5
by: DavidB | last post by:
Greetings I don't know if this is possible, but this group should be able to tell me. I have a webpage with a changing message board (I understand the problems with having changing text, but...
1
by: ngpost1 | last post by:
I have a Crystal Reports.Net report being generated from my C# application. I would like to change the background color of the details section (not the text mind you) of the report on certain...
6
by: spit0033 | last post by:
I have created a vertical menu with a white background, once a link is clicked i want that menu item's background color to change. Then once another menu item is clicked the first menu items...
2
by: bucchi | last post by:
Hi, I have an input field and I have to change the background color when the contents change. The contents are changed by a pop-up. On submit of the pop-up the contents change.How can I...
1
by: Ulf Malmros | last post by:
I want to change background color in a control in a form grid depending on the value in another control in the same grid. Can anyone giv me a hint about how to do this? Please!
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.