Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How do I show a particular section of a page when a button is clicked? Note that the section is on the same page as the button (i.e., I'm not trying to show a new page).
Posted
Updated 2-Sep-10 6:20am
v2
Comments
Ibrahim Yusuf 2-Sep-10 11:22am    
Reason for my vote of 1
not a question, ambiguous, and hard to understand
CPallini 2-Sep-10 11:58am    
You genious! e-mail address as nickname!!!

Multiviews


Multiviews allow for easily switching between sections of content:
HTML
<asp:MultiView runat="server">
    <asp:View runat="server">
        First Content
    </asp:View>
    <asp:View runat="server">
        Second Content
    </asp:View>
</asp:MultiView>

Panels


Panels are good for when each section isn't mutually exclusive:
HTML
<asp:Panel runat="server">
    Main Content
</asp:Panel>
<asp:Panel runat="server">
    Extra Content
</asp:Panel>

Controls


You can also show/hide pretty much any ASP.NET or HTML control so long as it has a runat="server" on it. Just set its Visible property to true or false.
HTML
<div id="myDiv" runat="server">
    Extra Content
</div>

C#
myDiv.Visible = false;
 
Share this answer
 
Comments
thatraja 3-Sep-10 1:50am    
Reason for my vote of 5
Well, complete answer with 3 different ways
You could use Panes and make them visible on click.
 
Share this answer
 
Apart from other answers above, you can also achieve it using JavaScripts.

On button click, raise a JavaScript method. In that method toggle the display/visibility of the section/panel you want to hide/show.

Use buttons OnClientClick property to do it.
 
Share this answer
 
If I understand your almost-a-question correctly, just create an event handler for the button click, and in that handler, hide the approrpiate "section" control. Of course, your "section" control should have an ID assigned so you can actually get to it.
 
Share this answer
 

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