473,597 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically Include (@reference) another Control or aspx file

Hello,

Can I include a control or another aspx file into a container aspx file on
the basis of some parameters?\
Like I want ControlA to be inserted in page index.aspx if the submit form
has some specific value, and ControlB otherwise.

-
AM

Nov 18 '05 #1
2 2341
yeap you can certainly add controls at run time (even the ones written as
user controls in .ascx)
you can use place holder or any other container to insert the control.
something like this.

if( a == 1)
{
MyUserControl1 mUC1 = new MyUserControl1( );
myPlaceHolder1. Controls.Add(mU C1);
}
else
{
MyUserControl2 mUC2 = new MyUserControl2( );
myPlaceHolder1. Controls.Add(mU C2);
}
--

Regards,

Hermit Dave (D'way)
http://hdave.blogspot.com

"Aamir Mahmood" <a@b.c> wrote in message
news:eT******** ******@tk2msftn gp13.phx.gbl...
Hello,

Can I include a control or another aspx file into a container aspx file on
the basis of some parameters?\
Like I want ControlA to be inserted in page index.aspx if the submit form
has some specific value, and ControlB otherwise.

-
AM

Nov 18 '05 #2
Hello Aamir,
Hello,

Can I include a control or another aspx file into a container aspx
file on
the basis of some parameters?\
Like I want ControlA to be inserted in page index.aspx if the submit
form
has some specific value, and ControlB otherwise.


You can use the Page.LoadContro l method to dynamically loading a control, and then place it somewhere in yout Page.Controls collection. But be aware that there can be issues with dynamically loading controls due to the way viewstate is handled.
Nov 18 '05 #3

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

Similar topics

2
2451
by: Eric | last post by:
I'm trying to dynamically load a user control using on the .NET framework (not Visual Studio). The control was designed in Visual Studio and is named: Disable.ascx The first line is: <%@ Control Language="c#" className="Disable1" src="Disable.ascx.cs" %> The host page for this control is named UserControl.aspx. The first 2 lines are: <%@ Reference control="Disable.ascx" %>
7
1891
by: Steve Bugden | last post by:
Hi, I am trying to reference an html page from an aspx file. The intention is that the html file will contain the content for my web site and the aspx will contain the navigation, logo etc. Then I am hoping I can maintain the html files separately via Frontpage. I have tried a server include i.e. <!-- #Include File="c:\somedirectory\somefilename.htm" -->
4
2432
by: TWEB | last post by:
I think I may have an IIS / ASP.Net Configuration issue that I need some guidance with resolving. Here's the problem: a) I have a .stm file. b) I referenc a .aspx file on this .stm file using a server-side-include directive: <!-- include virtual="../../foobar.aspx"--> c)When the .stm file is rendered: The .aspx file is included, but it doesn't look like the ASP.NET engine is processing the page, because I see the raw
7
3185
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb -- UC/ ----- Classic/
10
2424
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and load as a 3rd partial class. This would be handy so i can generate standard code into one of the partial classes, while having my custom code untouched
5
2866
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I am useing visual studio .net, the html and code are seperated. I have the following aspx code which has two user controls: <%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %> <%@ Register TagPrefix="Subway"...
5
3040
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over using the GetCallbackResult, but a recordset won't pass this way. Any ideas??? Thanks
4
1029
by: Waldy | last post by:
Hi there, I have a Web Application that uses a reference to a localhost web service. If however, I try to insert C# code blocks into the .aspx file I get an error when the application runs because localhost is unknown. Anyone know how to use a reference in a code block?
7
6646
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
0
7962
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7884
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6681
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5844
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3880
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.