Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every body 
i want to switch between two divs on mouse over using code behind i try this but no way
how it can be done ???
this is my code
< div id = "myDiv" runat = "server" >
< p > triallllllll </ p >
</ div >
< div id = "myDiv2" runat = "server" >
< p > triallllllll </ p >
</ div >
in code behind by default 
myDiv.Style.Add("display", "");
how can i make mydiv hidden and mydiv2 is visible on mouse over ???
my page is inherted from masterpage 

What I have tried:

< div id = "myDiv" runat="server" >
< p > triallllllll br mode="hold" />br mode="hold" />
< div id = "myDiv2" runat="server" >
< p > triallllllll br mode="hold" />br mode="hold" />

myDiv.Style.Add("display", "");
Updated 6-Apr-16 20:07pm
Sergey Alexandrovich Kryukov 7-Apr-16 0:21am    
It probably would be the worst idea to do it in code behind. Better do it in JavaScript. Or do the visibility criteria depend on some server-side calculations? But probably not; you are talking about mere mouse manipulations. And that's quite trivial.
Karthik_Mahalingam 7-Apr-16 0:46am    
try using javascript or jquery,its quite simpler.
Raghuveer Kasyap 7-Apr-16 0:58am    
Try accessing the Div from the Code behind.

Long answer short, You cannot do it.
But you could use asp panel instead of div. It will appear have same result and panel be use by code behide.

Panelid.Visible == false;

How to hide and show a panel in a web page using Visual Studio 2013 Express for Web - YouTube[^]
Share this answer
Use javascript coding

Refer below link
Share this answer
MR.alaa 7-Apr-16 4:52am    
i need to do it in mouseover and mouse leave
Sagar Haridas Shinde 7-Apr-16 5:01am    
Call Javascript on mouseover and mouseleave for ex. onmouseover="showstuff(" and onmouseleave="hidestuff(" also also we can use "document.getElementById ("your_control_id");" to get your element Id

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