Hi,
[using asp.net 2.0 framework]
I'm using loadControl to load an ascx into a variable.
This works ok but I'm having to load the control into an Object
variable
e.g.
Dim aWidget As Object = Me.LoadControl("/assets/components/
Widget.ascx")
I'd like to be able to load it into a variable of the proper type so I
can set properties.
I'm pretty sure I could do this with the 1.1 framework simply by
changing the ascx class to public, but this doesn't work with 2.0
Many thanks, 5 2073
Hello ?
The type have to bee available at the current context.
Then you can use DirectCast to cast into the specific wanted type.
Dim aWidget As MyType =
DirectCast(Me.LoadControl("/assets/components/Widget.ascx"), MyType)
--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
Hi Peter,
thanks for your reply.
The problem I'm having is that even if the type is public I can't do:
Dim aWidget As MyType
I get "MyType" is not defined
I've worked a way round this problem just by adding the control to the
page, rather than loading it dynamically.
Thanks,
Joe http://www.ratemyband.co.uk
Hi Peter,
it's in the same project, and I haven't set a specific namespace.
If I look at the class view I don't see my class
It's defined like this
Public Class myWidget
Inherits System.Web.UI.UserControl
and it's in a folder /assets/components/
Classes within /app_code are visisble, is this something to do with
it?
Thanks,
Joe
Hello Joe
Are you using a WebSite- or an WebApplications Project?
In a WebApplication Project, the namespaces would be generated automaticly
and like the folder they lies.
and it's in a folder /assets/components/
would give: Project.assets.components
Classes within /app_code are visisble, is this something to do with
it?
Both works on a WebApplication Project.
--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bonj |
last post by:
H
I want to make an ascx control with a DataGrid on it and make its bindings generic by using an ascx control, is there any way I can give each ascx control its own 'properties', like I want to make...
|
by: Josema |
last post by:
Hi to all,
I have a webform.aspx and inside i have a dropdown list with autopostback
and a place holder...
Depending of the selected index that the user selects in the dropdownlist i
load a...
|
by: Quentin |
last post by:
I need to import an *;ascx, as an object, in my class, that is in
myclass.vb. How can i do ? i saw the method LoadControl but i can't use it,
or maybe i did wrong, if could help me it would be very...
|
by: djscratchnsniffing |
last post by:
i know you can access an ascx's properties/methods from an aspx file.
Let's say you have an aspx file with two code-behind files(ascx files).
Can you access one of the ascx file's...
|
by: Sascha |
last post by:
Hi there,
I searched carefully through the web before finally deciding to post
this message, because I could not find a solution for my problem.
Hopefully someone will have a hint or explanation...
|
by: Green |
last post by:
Hi, All
I need to dynamically load a user control and change some properties on
the user control, and display in the aspx page. Unfortunately I failed,
nothing appears.
Please help me look at,...
|
by: ddelaney |
last post by:
I've seen this posted before in many places, but have yet to find a real fix.
I have a web application on dev server right now, and randomly, hours or
days, it returns the expception posted below. ...
|
by: DC |
last post by:
Hi,
I want to keep all my layout information in the .ascx file of a
UserControl. If I require layout related data in codebehind, I would
usually use properties defined in the codebehind, e.g.
...
|
by: google |
last post by:
Hi,
I'm using loadControl to load an ascx into a variable.
This works ok but I'm having to load the control into an Object
variable
e.g.
Dim aWidget As Object =...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |