C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » JavaScript »

How to set div on ,off or visible ,invisible


Posted Date: 04 Jul 2009      Posted By: Macson      Member Level: Gold     Points: 1   Responses: 7



how to set div on ,off or visible ,invisible




Responses

Author: rajesh    04 Jul 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

inline page

<div id="id1" runat="server">

</div>

code behind

HtmlControl div = (HtmlControl)form1.FindControl("id1");
div.Visible = false;



Author: Ashok    04 Jul 2009Member Level: GoldRating: 3 out of 53 out of 53 out of 5     Points: 3

Hi,

Try this code.....


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" OnClientClick="visibleDiv('Div1'); return false;" runat="server" Text="Show Div" />
</div>
<div id='Div1' style="visibility:hidden">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button2" OnClientClick="visibleDiv('Div1'); return false;" runat="server" Text="Hide Div" />
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript">


function visibleDiv(id)
{
if(document.getElementById(id).style.visibility=="hidden")
{
document.getElementById(id).style.visibility="visible";
}
else
{
document.getElementById(id).style.visibility="hidden";
}

}
</script>



Please rate this post, if it is useful for you.

Thanks & Regards
Ashok



Author: Miss Meetu Choudhary    04 Jul 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

what ever Rajesh has told is good for code behind. if you want to use it in JavaScript or directly on .aspx then use Visiblity like

if(document.getElementById(divid).style.visibility=="hidden")
{
document.getElementById(divid).style.visibility="visible";
}
else
{
document.getElementById(divid).style.visibility="hidden";
}


Thanks and Regards
Miss Meetu Choudhary (Site Coordinator)
Go Green Save Green
My Profile on Google



Author: R.Jaya kumar (JK)    04 Jul 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi

try this

function TestDiv()
{
document.getElementById("Div1").style.visibility ='visible';
document.getElementById("Div1").style.visibility ='hidden';
}

Thanks and Regards
Jayakumar

Do not forget to Rate the post...



Author: shankar v    04 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

by set runat="server" for div and can make it visible true false etc by server side code..

Regards & Thanks
Shankar V
www.teaminnovative.in



Author: Harish Shanker    06 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

if(document.getElementById("id").style.visibility=="none") {
document.getElementById("id").style.visibility="block";
}
else
{
document.getElementById("id").style.visibility="none";
}

Regards,
HARISH SHANKER A S
C#.Net programmer



Author: Devendra    06 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

style="visibility:hidden; display:none"
style="visibility:visibile; display:block"



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Combo box in javascript
Previous : Javascript calender control
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use