As the title states, I'm changing the forecolor of a linkbutton when it is clicked on. However, I'd like for the color to go back to its original once I click on another item, ie only the item clicked should be red.
Here's what I have:
Code to change the color:
Sorry if it looks like a mess....
Here's what I have:
Code:
<asp:datalist id="dlCategories" runat="server">
<ItemTemplate>
<P class="wht_14" style="MARGIN: 8px 18px 2px 0px" align="right"><b>
<asp:LinkButton id="Linkbutton1" Runat="server" CommandArgument='<%# Container.DataItem("categoryID") %>' CommandName="Edit"><%#Container.DataItem("CategoryName")%></asp:LinkButton></b></P>
<!-- Begin Product Listing -->
<asp:Panel id="PanelProd" runat="server" Visible="false">
<asp:DataList ID="dlProd" Runat="server">
<ItemTemplate>
<P class="wht_11" style="MARGIN: 0px 26px 4px 0px" align="right">
<asp:Image ID="imgArrow" Runat="server" Visible="False" ImageUrl="/images/ico_arrowRight.gif"></asp:Image>
[b] <asp:LinkButton id="linkButton2" Runat="server" OnClick="ProductDetailClicked" CommandArgument='<%# Container.DataItem("productsID") %>'><%#Container.DataItem("ProductName")%></asp:LinkButton></P>
[/b] </ItemTemplate>
</asp:DataList>
</asp:Panel>
<!-- End Product Listing -->
</ItemTemplate>
</asp:datalist>
Code to change the color:
Code:
Public Sub ProductDetailClicked(ByVal sender As Object, ByVal e As EventArgs)
PanelMainProducts.Visible = False
PanelProduct.Visible = True
myConnection = New SqlConnection(conString)
myConnection.Open()
mycommand = New SqlCommand("getSpecificProduct", myConnection)
mycommand.CommandType = CommandType.StoredProcedure
Dim objButton As LinkButton
If Session("ProdID") = "" Then
objButton = CType(sender, LinkButton)
mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
mycommand.Parameters("@productsID").Value = objButton.CommandArgument
Else
mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
mycommand.Parameters("@productsID").Value = sender
End If
myReader = mycommand.ExecuteReader
Me.Bind_Data(myReader)
myConnection.Close()
[b] objButton.ForeColor = System.Drawing.Color.Red[/b]
End Sub
Sorry if it looks like a mess....