Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
JavaScript
<script language="javascript" type="text/javascript">
       function fun1() {

           document.getElementById("chng_profilepic").style.visibility = "visible";
          
       }

       function fun2() {
           document.getElementById("chng_profilepic").style.visibility = "hidden";
          
       }
    
    </script>

and below is aspx page code
ASP.NET
<img src='<%#"uploaded1/"+ Eval("image") %>' alt='<%# Eval("image") %>' id="profile_pic" style="margin-left:4px; width:180px"
height="200" onmouseover="fun1()"  önmouseout="fun2()" />

 <asp:Button ID="chng_profilepic" runat="server" Text="change profile" OnClick="chng_profilepic_Click" />

this content is on page which is attached with master page and on mouse over and onmouseout is not working so how to do it?
Both Image and button is inside a formview
Posted
Updated 6-Oct-13 19:55pm
v6
Comments
[no name] 7-Oct-13 0:51am    
I think you are missing functioning sign (()).!!
try that then check like this
<asp:Button ID="chng_profilepic" runat="server" Text="change profile" OnClick="chng_profilepic_Click()" />
tanweer 7-Oct-13 0:58am    
no nned to add () sign here bro, this will not work

try this
JavaScript
<script language="javascript" type="text/javascript">
       function fun1() {
 
           document.getElementById('<%=chng_profilepic.ClientID%>').style.visibility = "visible";
          
       }
 
       function fun2() {
           document.getElementById('<%=chng_profilepic.ClientID%>').style.visibility = "hidden";
          
       }
    
    </script>
 
Share this answer
 
Comments
Omprakash Kukana 7-Oct-13 1:03am    
Compiler Error Message: CS0103: The name 'chng_profilepic' does not exist in the current context
Zafar A khan 7-Oct-13 1:08am    
is the button inside grid ? <asp:Button ID="chng_profilepic" runat="server" Text="change profile" OnClick="chng_profilepic_Click" />
if it is not inside the grid will not give an error
Omprakash Kukana 7-Oct-13 1:21am    
no this is inside a form view
Zafar A khan 7-Oct-13 1:35am    
this will not work inside formview use firebug to get the correct id of chng_profilepic
and then give it in javascript code.
document.getElementById('get this id by using firbug').style.visibility = "hidden";
OR easy way is to use jquery css selector
Omprakash Kukana 7-Oct-13 1:54am    
can u tell me how to use firebug in my vs2010 i havent yet used firebug
Hi,
Accessing Elements inside gridview or repeater directlyis quite difficult, try jQuery instead by its css property
JavaScript
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
   <script language="javascript" type="text/javascript">
       function fun1() {
           $('.MyButton').css("display", "block");
       }
       function fun2() {
           $('.MyButton').css("display", "none");
       }
   </script>

and add cssclass property to your button like
ASP.NET
<img src="<%#"uploaded1/"+ Eval("image") %>" alt="<%# Eval("image") %>"  id="profile_pic"
           style="margin-left: 4px; width: 180px" height="200" onmouseover="fun1()" onmouseout="fun2()" />
      <asp:button id="chng_profilepic" runat="server" text="change profile" onclick="chng_profilepic_Click" cssclass="MyButton" xmlns:asp="#unknown" />
 
Share this answer
 
v3
Comments
Omprakash Kukana 7-Oct-13 1:49am    
not working dear
tanweer 7-Oct-13 1:51am    
what is the issue, did you get any error?
Omprakash Kukana 7-Oct-13 2:02am    
no any error but button is always visible and css design not working
tanweer 7-Oct-13 2:06am    
did you add jQuery on your page, because it depends on jQuery
Omprakash Kukana 7-Oct-13 2:17am    
how to add jquery?
XML
<script language="javascript" type="text/javascript">
       function fun1() {

           document.getElementById("chng_profilepic").style.display= 'block';

       }

       function fun2() {
           document.getElementById("chng_profilepic").style.display= 'none';

       }

    </script>
 
Share this answer
 
Comments
Omprakash Kukana 7-Oct-13 1:21am    
button is not hiding always visible

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