Click here to Skip to main content
15,915,324 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I am trying to access an html anchor inside a login view but it is not working,iam always getting nothing when making .FindControl.This is my code :
<asp:LoginView ID="LoginView2" runat="server">
                                   <anonymoustemplate>
                                       <a href="~/Login.aspx" id="A15"  runat="server">
                                           <img id="Img4"  runat="server" alt="Login" width="160" height="59" border="0" src="images/Login.jpg"
                                               onmouseover="this.src='images/Login-hover.jpg'"  önmouseout="this.src='images/Login.jpg'" />
                                   </anonymoustemplate>
                                   <rolegroups>
                                       <asp:RoleGroup Roles="Members">
                                           <contenttemplate>
                                               <a href="~/Members/CustomersList.aspx" id="A44"  runat="server">
                                                   <img id="Img4"  runat="server" alt="Profle" width="160" height="59" border="0" src="/images/profile.jpg"
                                                       onmouseover="this.src='/images/profile_hover.jpg'"  önmouseout="this.src='/images/profile.jpg'" />
                                           </contenttemplate>

                                   </rolegroups>

Here is my server side code :
VB
If TryCast(ctrl, LoginView) IsNot Nothing Then

              If HttpContext.Current.User.Identity.IsAuthenticated = False Then
                  Dim a As New HtmlControls.HtmlAnchor
                  a = ctrl.FindControl("A15")

                  If a.HRef.ToUpper = Item.ToUpper Then
                      For Each imag As HtmlControls.HtmlImage In a.Controls
                          If TryCast(imag, HtmlControls.HtmlImage) IsNot Nothing Then
                              DirectCast(imag, HtmlControls.HtmlImage).Attributes.Add("onMouseOver", "")
                              DirectCast(imag, HtmlControls.HtmlImage).Attributes.Add("onMouseOut", "")
                              DirectCast(imag, HtmlControls.HtmlImage).Src = "~/images/login-hover.jpg"
                          End If
                      Next
                  End If
              End If
          End If


Please help ,and thanks in advance.
Posted
Updated 16-Aug-11 21:54pm
v2

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