Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when the mouse hovers over the image, it changes opacity (and ok)

when i click an image (.CSSImageButton:active) change color, but at the same time he loses focus (effect .CSSImageButton)

the objective is to report the focus on the image after the click

this has no effect because CSS verifies the loss of focus

 protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {      
        DataList1.SelectedIndex = e.Item.ItemIndex;
     
        Image1.BorderStyle = BorderStyle.Ridge;
        Image1.BorderColor = System.Drawing.Color.DarkBlue;

        //get the current index
        DataList1.SelectedIndex = e.Item.ItemIndex;

       // ???? is possible to set the focus on curentItem ......
}


What I have tried:

CSS style

.CCSImageButton:hover
{      
   border-width:5px;
   border-color: yellow; 
   border-style:ridge;
   opacity : 1;
}

.CCSImageButton
{  
   border-width:2px;
   border-style:groove;
   opacity : 0.5;
} 
.CCSImageButton:active
{
   border-width:5px;
   border-color: red; 
   border-style:ridge;
   opacity : 1;
}


DataList

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
             <ContentTemplate>
               <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Table" RepeatColumns="0" SeparatorStyle-HorizontalAlign="NotSet" SelectedItemStyle-Wrap="False" SelectedItemStyle-HorizontalAlign="NotSet" HorizontalAlign="NotSet" ItemStyle-HorizontalAlign="NotSet" FooterStyle-Wrap="False" OnItemCommand="DataList1_ItemCommand">
                 
                 <ItemTemplate>
                    <td>                                       
                     <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# Eval("thumbs") %>' Height="150px" OnClick="ImageButton1_Click" ImageAlign="Middle" EnableTheming="False" CssClass="CCSImageButton" />
                     asp:Label ID="Label1" runat="server" Text=' <%# Eval("descrizione") %>' Visible="true"></asp:Label>                           
                      <asp:Label ID="Label3" runat="server" Text=' <%# Eval("fullimage") %>' Visible="false"></asp:Label> 
                    </td>
                  </ItemTemplate>
                 </asp:DataList>
              </ContentTemplate>             
            </asp:UpdatePanel>
Posted
Comments
[no name] 29-Jan-18 4:48am    
There is a property called AutoFocus for a button.Did you try setting them?Because i don't see them

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900