473,327 Members | 1,979 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,327 software developers and data experts.

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 2332
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(mUC1);
}
else
{
MyUserControl2 mUC2 = new MyUserControl2();
myPlaceHolder1.Controls.Add(mUC2);
}
--

Regards,

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

"Aamir Mahmood" <a@b.c> wrote in message
news:eT**************@tk2msftngp13.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.LoadControl 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
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: <%@...
7
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...
4
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...
7
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 --...
10
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...
5
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...
5
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...
4
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...
7
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.