How to make div visible & not visible after clicking button in MVC3.

Posted by Sampath1750 under ASP.NET on 2/29/2012 | Points: 10 | Views : 31386 | Status : [Member] | Replies : 3
Hi all,
How to make div visible & not visible after clicking button in MVC3.
Thanks,
Sampath bejugama.




Responses

Posted by: Blessyjees on: 2/29/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can use javascript to hide and show the div

document.getElementById("divHide").style.visibility='hidden' for hide and document.getElementById("divHide").style.visibility='visible' for show.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sampath1750, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sampath1750 on: 2/29/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Blessy,
Am new to MVC3,
How can i write above code after button click in MVC3, can u give me some sample code.
Thanks,
Sampath

Sampath1750, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 2/29/2012 [Member] Bronze | Points: 25

Up
0
Down
hi,

try this

<div><asp:Button ID="btnAdd" runat="server" Text="Add" OnClientClick="return ShowHide()" onclick="btnAdd_Click" /></div>

<div>

<div id="divContainer" runat="server" style="visibility:visible" >
<asp:Label ID="lbl" runat="server" Text="Label"></asp:Label>
<br />
</div>
</div>

function ShowHide() {

if (document.getElementById("divContainer").style.visibility == 'visible') {
document.getElementById("divContainer").style.visibility = 'hidden';
}
else {
document.getElementById("divContainer").style.visibility = 'visible';
}
return false;
}


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sampath1750, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response