473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Add control to asp:PlaceHolder on asp.net page from user control on same page

Dan
I have an asp.net page default.aspx with a user control and a placeholder
control.

<html>
<body>
<form id="myform" method="post" runat="server" />
<PageHeader:Header id="header1" runat="server" />
<asp:PlaceHolder ID="content" runat="server" />
</form>
</body>
</html>

In my user control I have 5 linkbuttons. I would like to have each of these
linkbuttons load a different user control into the placeholder on the
default.aspx page. Is this possible? If so how can I add my user controls
to the placeholder from another user control?

Thanks,

Dan
Nov 18 '05 #1
1 2933
You've got different options. Just make sure you can modify the controls
collection of the placeholder control on the page. You can do this in
different ways. You can create a public property or method on the page
class, and by the Page property on your usercontrol, you can invoke the page
method or work with the property. You could also let your page class pass
the reference of the placeholder, or the placeholders control collection, to
a property on your usercontrol.

if you would use a method on the page class then you could do something like
this

default.aspx.cs

public void SetPlaceHolderControl (Control control) {
content.Controls.Clear();
content.Controls.Add(control);
}

in your header usercontrol put something like this in the eventhandler of
the linkbuttons

((default)Page).SetPlaceHolderControl(Page.LoadCon trol("OtherUserControl.asc
x"));

where default is the name of your page class

Christophe
"Dan" <da******@test.com> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
I have an asp.net page default.aspx with a user control and a placeholder
control.

<html>
<body>
<form id="myform" method="post" runat="server" />
<PageHeader:Header id="header1" runat="server" />
<asp:PlaceHolder ID="content" runat="server" />
</form>
</body>
</html>

In my user control I have 5 linkbuttons. I would like to have each of these linkbuttons load a different user control into the placeholder on the
default.aspx page. Is this possible? If so how can I add my user controls to the placeholder from another user control?

Thanks,

Dan

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
2
by: Peter | last post by:
Hello! Please, could anybody tell me, is it possible to run an asp page as particular user? I have this situation where I have one shared folder on particular server and this folder is shared...
23
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
2
by: Brett Robichaud | last post by:
I'm trying to create a Page class that I derive all others from. This page class will look for an asp:placeholder and insert some html at that point. I can see how I can create new HTML controls...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
1
by: wanaruk | last post by:
Hi all. I am working on a legacy application written in Classic ASP with VB6 COM+ components running on Windows 2003 Adv Server (32bit). There is one page in the app that uses Secure FTP to send...
3
by: 200dogz | last post by:
In terms of disaplying text on the server side, which one is the better choice - an asp:Label or an asp:Placeholder? The only difference between the two that I know is that label puts a <span> tag...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.