Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2012, 06:59 AM
Authorized User
 
Join Date: Feb 2007
Posts: 39
Thanks: 2
Thanked 2 Times in 2 Posts
Default Replace Content based on button click

Hi all,
I have in my Default.aspx a simple table like this:

HTML Code:
<table>
<tr>
<td>
asp:Content ID="ContentLeft" ContentPlaceHolderID="HeadContent" runat="server">
<asp:Button ID="btn1" runat="server" Text="First form" />
<asp:Button ID="btn2" runat="server" Text="Second form" />
<asp:Button ID="btn3" runat="server" Text="Third form" />
/asp:Content>
</td>
<td>
<asp:Content ID="ContentCenter1" ContentPlaceHolderID="MainContent" runat="server">
</td>
</tr>
</table>
Is it possible to replace the ContentCenter based on the button clic?

For example, if the user clicks on btn2, I need to replace the ContentCenter1 with another content, placed (for example) in the Default.aspx itself.

Luigi
 
Old February 14th, 2012, 02:34 PM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default use iFrame

you can use 'iframe'
Code:
<table>
<tr>
<td>
<asp:Content ID="ContentLeft" ContentPlaceHolderID="HeadContent" runat="server">
<a href="FirstForm.aspx"  target="myFrame"  >First Form</a>
<a href="SecondForm.aspx" target="myFrame"  >Second Form</a>
<a href="ThirdForm.aspx"  target="myFrame"  >Third Form</a>
</asp:Content>
</td>
<td>
<iframe name="myFrame" id="myFrame" border="no" width="100%" height="100%"></iframe>
</td>
</tr>
</table>


You can't replace a asp.net control with other (because of runat="server"). you can load at runtime but you can't replace existing item
often UserControls are loaded at runtime:
aspx page:
Code:
<td id="td1" runat="server"></td>
aspx.cs :
Code:
MyUserControl ctrl = LoadControl("~/UserControls/MyUserControl.ascx");
td1.Controls.Add(ctrl);
note that this control will be distroyed after postback
__________________
happy every time, happy every where

Reza Baiat
 
Old February 14th, 2012, 04:22 PM
Authorized User
 
Join Date: Feb 2007
Posts: 39
Thanks: 2
Thanked 2 Times in 2 Posts
Default

Thank you Ir, I'll try.

Luigi





Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight a row based on cell content needhelptdot Excel VBA 0 September 8th, 2011 12:42 PM
Continous Form, resize based on content (Tricky) hkmulligan Access 2 August 13th, 2007 12:02 PM
How we can replace content of WebPartzone anurag_ur ASP.NET 2.0 Basics 0 June 24th, 2006 10:15 AM
How we can replace content of WebPartzone anurag_ur ASP.NET 2.0 Professional 0 June 24th, 2006 10:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.