473,714 Members | 2,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic user controls in compiled site

I am moving a web application from 1.1 to 2.0
This site builds pages dynamically as :
PlaceHolder.Con trols.Add(LoadC ontrol("~/Controls/Ctl1.ascx"));
Everything is working fine as long as the web site is updateable - the .ascx
files exist on disk.
I would like to use the non-updateable and single assembly options - no
..ascx files.

I thought that maybe this would work :
PlaceHolder.Con trols.Add(LoadC ontrol("AppName Space.Controls. Ctl1",null));
This creates the proper object as defined by the code behind class.
However it never creates any child controls - textboxes etc.

Is there an additional step required to instantiate the page controls ?
Is there a class for the .ascx half of the control that I should be loading
instead ?

...

Gerry
May 4 '07 #1
2 1938
if you pass a string to LoadControl, it wants the path to the file. to
load from the assembly, you need to pass the type and construction
parameters.
PlaceHolder.Con trols.Add(
LoadControl(typ eof(MyControlCl assName),null)) ;

be sure to specify the class name in the page directive.
-- bruce (sqlwork.com)

germ wrote:
I am moving a web application from 1.1 to 2.0
This site builds pages dynamically as :
PlaceHolder.Con trols.Add(LoadC ontrol("~/Controls/Ctl1.ascx"));
Everything is working fine as long as the web site is updateable - the .ascx
files exist on disk.
I would like to use the non-updateable and single assembly options - no
.ascx files.

I thought that maybe this would work :
PlaceHolder.Con trols.Add(LoadC ontrol("AppName Space.Controls. Ctl1",null));
This creates the proper object as defined by the code behind class.
However it never creates any child controls - textboxes etc.

Is there an additional step required to instantiate the page controls ?
Is there a class for the .ascx half of the control that I should be loading
instead ?

...

Gerry

May 4 '07 #2
thanks bruce

I am using LoadControl(typ eof("MyControls .MyCtl"),null);
and this does create the proper control. however no child controls are
never created.
I tried calling CreateChildCont rols() in the user control OnInit &
OnPrerender methods after which Controls collection is always empty.

by "specify the class name in the page directive" - do you mean in the user
..ascx Control directive ? or in a Register directive on the .aspx ?
The Control directive looks like this : <%@ Control Language="c#"
AutoEventWireup ="True" Codebehind="MyC tl.ascx.cs"
Inherits="MyCon trols.MyCtl"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/nav4-0" %>

using the Register directive on the page defeats the whole purpose of
dynamic control creation.

gerry

"bruce barker" <no****@nospam. comwrote in message
news:O1******** ******@TK2MSFTN GP02.phx.gbl...
if you pass a string to LoadControl, it wants the path to the file. to
load from the assembly, you need to pass the type and construction
parameters.
PlaceHolder.Con trols.Add(
LoadControl(typ eof(MyControlCl assName),null)) ;

be sure to specify the class name in the page directive.
-- bruce (sqlwork.com)

germ wrote:
>I am moving a web application from 1.1 to 2.0
This site builds pages dynamically as :
PlaceHolder.Co ntrols.Add(Load Control("~/Controls/Ctl1.ascx"));
Everything is working fine as long as the web site is updateable - the
.ascx files exist on disk.
I would like to use the non-updateable and single assembly options - no
.ascx files.

I thought that maybe this would work :
PlaceHolder.Co ntrols.Add(Load Control("AppNam eSpace.Controls .Ctl1",null));
This creates the proper object as defined by the code behind class.
However it never creates any child controls - textboxes etc.

Is there an additional step required to instantiate the page controls ?
Is there a class for the .ascx half of the control that I should be
loading instead ?

...

Gerry

May 4 '07 #3

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

Similar topics

13
2894
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for trousers and hats. when the user selects an option in the garment combo box, the options available...
10
3225
by: moondaddy | last post by:
I'm writing an ecommerce app in asp.net/vb.net and need to make the pages searchable and crawlable by spiders, particularly Google's. As far as I know, if my pages's contents are mostly populated by user controls on a single page and I call these different controls by passing one or more parameters like this: myweb.com/default.aspx?MenuID=44, then the spiders aren't going to be able do to anything with this. asp.net offers lots of great...
7
2881
by: Alan Silver | last post by:
Hello, I am just looking at VWD and seeing what needs doing to take an existing site I've written by hand and importing it into VWD. I've already discovered that I need to rename my code-behind files to match the .aspx file name so VWD will tie the two together, and I'm now wondering what to do about the location of the code-behind files. Is there any set convention for where the code-behind files live? I have been putting them in the...
4
304
by: rn5a | last post by:
Assume that a ASPX page uses a user control named Address.ascx which has 2 TextBoxes. This ASCX page creates 2 properties named 'Address' & 'City' using the Get & Set statements: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)
3
1881
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of doing this, which is declared as: public class ConfigurableRepeater : WebControl.
9
3627
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
2
1215
by: Lloyd Sheen | last post by:
Ok I have created a small testbed site for testing and I am have a problem with the terms Usercontrol, Webcontrol, etc. What I need to do in the long run is have a page using AJAX and having dynamically loaded controls on the page. So what I did was first create a page with two buttons. First button will load a Label control into a placeholder. After execution and clicking the button the label shows in the page.
0
2940
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
0
1915
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
0
8795
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
8701
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,...
1
9068
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7942
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
6621
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
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3155
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.