473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic use of UserControl

I have a ASP.Net 1.1 application where I have several usercontrols, one is
called DetailLine, that I add to a panel dynamically. I am converting the
app to ASP.Net 2.0 and I cant do this anymore. LineType1 inherits from
DetailLine which inherits from UserControl.

1 Dim ucLine As DetailLine ' this line bombs

2 ucLine = CType(Page.Load Control("..\Use rControls\LineT ype1.ascx"),
DetailLine)

3 pnlDemoLines.Co ntrols.Add(ucLi ne)
I cant understand why line one bombs in 2.0, why cant i see any of the
classes I created in my Inellisense? Here's the code behind the DetailLine
class:

Partial Class UserControls_De tailLine

Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer

Public ReadOnly Property InvoiceNumber() As Integer 'example property

Get

Return iInvoiceNumber

End Get

End Property

End Class

Thanks in advance, DougS
Jun 28 '07 #1
3 1682
DougS,

As per the code below - the actual control type is now
UserControls_De tailLine - hence DetailLine is not a valid type

"DougS" wrote:
I have a ASP.Net 1.1 application where I have several usercontrols, one is
called DetailLine, that I add to a panel dynamically. I am converting the
app to ASP.Net 2.0 and I cant do this anymore. LineType1 inherits from
DetailLine which inherits from UserControl.

1 Dim ucLine As DetailLine ' this line bombs

2 ucLine = CType(Page.Load Control("..\Use rControls\LineT ype1.ascx"),
DetailLine)

3 pnlDemoLines.Co ntrols.Add(ucLi ne)
I cant understand why line one bombs in 2.0, why cant i see any of the
classes I created in my Inellisense? Here's the code behind the DetailLine
class:

Partial Class UserControls_De tailLine

Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer

Public ReadOnly Property InvoiceNumber() As Integer 'example property

Get

Return iInvoiceNumber

End Get

End Property

End Class

Thanks in advance, DougS
Jun 29 '07 #2
Yes, I've tried that Sergey. It still doesnt work. I tried creating another
class and inherit from the UserControls_De tailLine class:

Base class:

Partial Public Class UserControls_De tailLine
Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer
Public ReadOnly Property InvoiceNumber() As Integer
Get
Return iInvoiceNumber
End Get
End Property
End Class

Inherited class:

Partial Class UserControls_Li neType1
Inherits UserControls_De tailLine ' THIS LINE WONT COMPILE
Public Property Test1' rest of code
End Property
End Class

"Sergey Poberezovskiy" <Se************ *****@discussio ns.microsoft.co mwrote
in message news:6D******** *************** ***********@mic rosoft.com...
DougS,

As per the code below - the actual control type is now
UserControls_De tailLine - hence DetailLine is not a valid type

"DougS" wrote:
>I have a ASP.Net 1.1 application where I have several usercontrols, one
is
called DetailLine, that I add to a panel dynamically. I am converting the
app to ASP.Net 2.0 and I cant do this anymore. LineType1 inherits from
DetailLine which inherits from UserControl.

1 Dim ucLine As DetailLine ' this line bombs

2 ucLine = CType(Page.Load Control("..\Use rControls\LineT ype1.ascx"),
DetailLine)

3 pnlDemoLines.Co ntrols.Add(ucLi ne)
I cant understand why line one bombs in 2.0, why cant i see any of the
classes I created in my Inellisense? Here's the code behind the
DetailLine
class:

Partial Class UserControls_De tailLine

Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer

Public ReadOnly Property InvoiceNumber() As Integer 'example property

Get

Return iInvoiceNumber

End Get

End Property

End Class

Thanks in advance, DougS

Jun 29 '07 #3
DougS,

I suspect that you are using ASP.Net default website setup - file project
(as opposed to web project), and your UserControls folder is not under
App_Code - then it will not be visible to other objects within your website.
The ASP model have changed quite a bit from 1.1 to 2.0 and it took me some
time to get used to new model.

My suggestion would be to try utilizing VS upgade wizard to see what sort of
objects VS creates. Also do not forget to backup your 1.1 before - though
provides backup as an option during conversion, I usually prefer to know
exactly where things are.

Then you will notice that VS puts classes for your user controls inside
App_Code folder, and then the implementations inside UserControls folder will
inherit those. This way your controls are visible across the site and your
site structure is preserved (sort of).

Please let me know if what I wrote made sense

"DougS" wrote:
Yes, I've tried that Sergey. It still doesnt work. I tried creating another
class and inherit from the UserControls_De tailLine class:

Base class:

Partial Public Class UserControls_De tailLine
Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer
Public ReadOnly Property InvoiceNumber() As Integer
Get
Return iInvoiceNumber
End Get
End Property
End Class

Inherited class:

Partial Class UserControls_Li neType1
Inherits UserControls_De tailLine ' THIS LINE WONT COMPILE
Public Property Test1' rest of code
End Property
End Class

"Sergey Poberezovskiy" <Se************ *****@discussio ns.microsoft.co mwrote
in message news:6D******** *************** ***********@mic rosoft.com...
DougS,

As per the code below - the actual control type is now
UserControls_De tailLine - hence DetailLine is not a valid type

"DougS" wrote:
I have a ASP.Net 1.1 application where I have several usercontrols, one
is
called DetailLine, that I add to a panel dynamically. I am converting the
app to ASP.Net 2.0 and I cant do this anymore. LineType1 inherits from
DetailLine which inherits from UserControl.

1 Dim ucLine As DetailLine ' this line bombs

2 ucLine = CType(Page.Load Control("..\Use rControls\LineT ype1.ascx"),
DetailLine)

3 pnlDemoLines.Co ntrols.Add(ucLi ne)
I cant understand why line one bombs in 2.0, why cant i see any of the
classes I created in my Inellisense? Here's the code behind the
DetailLine
class:

Partial Class UserControls_De tailLine

Inherits System.Web.UI.U serControl

Private iInvoiceNumber As Integer

Public ReadOnly Property InvoiceNumber() As Integer 'example property

Get

Return iInvoiceNumber

End Get

End Property

End Class

Thanks in advance, DougS


Jul 2 '07 #4

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

Similar topics

1
7580
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
2
3342
by: John Ninan | last post by:
I am creating Dynamic Usercontrol in Asp.net application. In this application I have a combobox(aspx Page). Which contains various items. Based on item selected I am dynamically populating Usercontrols. Problem: When I am populating dynamic user control (ascx) page in Page_load event it works fine for the first list item from combobox. When I change the item in combobox, usercontrols are build properly but value will be same in second...
4
2209
by: Luca | last post by:
HI, I've a asp.net application that add a dynamic usercontrol with a button. If i've tried to click it Click Event don't load. But into a static usercontrol it's happens. Anyone can help me?
4
10602
by: Fueled | last post by:
Hi everyone! I've made quite a lot of research on this, and I've tried a couple of proposed solutions. Nothing has worked for me, but I feel there's not much I'm missing. So I'm turning to this group and its experts for answers. So : - I've got a main page (main.aspx) - On this page, I've got a button (btnArchive), on whose click I dynamically add a UserControl (archive.ascx) to the main page.
2
3831
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At runtime, the placeholder control adds a dropdownlist where I would like it to redirect the user to a different page dependent on the selection they make from the dropdownlist. I've tried writing the delegate and the event handler both in the
4
4193
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it would be initialized and have its event handlers set up, then after Load, the control would call its...
7
3003
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
3
2106
by: s.bussing | last post by:
Hi, I have been reading for hours now, but I'm still not able to solve my problem, though a lot of people are struggling with something similar. On my page I have a nested repeater. In the inner repeater for each item a usercontrol is added which has a textbox and two buttons. No I know that when the page is posted back (in my case by pushing one of the buttons of the control), I have to recreate all the dynamic control. I want to...
0
2937
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
1913
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
8604
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
9160
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...
1
8897
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
8862
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
7729
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
6521
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
4370
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2002
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.