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

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.LoadControl("..\UserControls\LineType1. ascx"),
DetailLine)

3 pnlDemoLines.Controls.Add(ucLine)
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_DetailLine

Inherits System.Web.UI.UserControl

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 1667
DougS,

As per the code below - the actual control type is now
UserControls_DetailLine - 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.LoadControl("..\UserControls\LineType1. ascx"),
DetailLine)

3 pnlDemoLines.Controls.Add(ucLine)
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_DetailLine

Inherits System.Web.UI.UserControl

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_DetailLine class:

Base class:

Partial Public Class UserControls_DetailLine
Inherits System.Web.UI.UserControl

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

Inherited class:

Partial Class UserControls_LineType1
Inherits UserControls_DetailLine ' THIS LINE WONT COMPILE
Public Property Test1' rest of code
End Property
End Class

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:6D**********************************@microsof t.com...
DougS,

As per the code below - the actual control type is now
UserControls_DetailLine - 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.LoadControl("..\UserControls\LineType1. ascx"),
DetailLine)

3 pnlDemoLines.Controls.Add(ucLine)
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_DetailLine

Inherits System.Web.UI.UserControl

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_DetailLine class:

Base class:

Partial Public Class UserControls_DetailLine
Inherits System.Web.UI.UserControl

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

Inherited class:

Partial Class UserControls_LineType1
Inherits UserControls_DetailLine ' THIS LINE WONT COMPILE
Public Property Test1' rest of code
End Property
End Class

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:6D**********************************@microsof t.com...
DougS,

As per the code below - the actual control type is now
UserControls_DetailLine - 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.LoadControl("..\UserControls\LineType1. ascx"),
DetailLine)

3 pnlDemoLines.Controls.Add(ucLine)
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_DetailLine

Inherits System.Web.UI.UserControl

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
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...
2
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...
4
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
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...
2
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...
4
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...
7
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...
3
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...
0
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...
0
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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,...

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.