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

Using a base class for a loaded UC (Part III)

Continuing my ongoing journey through base classes...

Thanks to help from some folks, I think I've gotten my syntax close (but not
quite) where it needs to be.

What I am doing: trying to load a variety of usercontrols programtically and
then assigning property values to them.

What I have:

I created a baseclass for these controls that will be loaded:

-------------------------
Public Class BaseLoadedControl
Inherits System.Web.UI.UserControl

public siteID as String

End Class
-------------------------
Then, in my usercontrol that I am using to then load one of these controls,
I have this:

-------------------------
dim customContentControl as BaseLoadedControl
customContentControl = CType(Page.LoadControl(thecontrol),
BaseLoadedControl)
'theControl = the string of the specific control I am loading...such as
sample.ascx
-------------------------

The problem is that gives me an 'invalid cast' error.

So, once again, I'm stuck. Anyone see where my logic and/or syntax may be
off?

-Darrel
Nov 19 '05 #1
2 895
Hello darrel,

In the codebehind for your ascx file, you'll have a line that says something
like (forgive my VB)

public class MyUserControl Inherits UserControl

The inherits needs to be modified to be BaseLoadedControl (or whatever you
named your base class).

--
Matt Berther
http://www.mattberther.com
Continuing my ongoing journey through base classes...

Thanks to help from some folks, I think I've gotten my syntax close
(but not quite) where it needs to be.

What I am doing: trying to load a variety of usercontrols
programtically and then assigning property values to them.

What I have:

I created a baseclass for these controls that will be loaded:

-------------------------
Public Class BaseLoadedControl
Inherits System.Web.UI.UserControl
public siteID as String

End Class
-------------------------
Then, in my usercontrol that I am using to then load one of these
controls, I have this:

-------------------------
dim customContentControl as BaseLoadedControl
customContentControl = CType(Page.LoadControl(thecontrol),
BaseLoadedControl)
'theControl = the string of the specific control I am loading...such
as
sample.ascx
-------------------------
The problem is that gives me an 'invalid cast' error.

So, once again, I'm stuck. Anyone see where my logic and/or syntax may
be off?

-Darrel


Nov 19 '05 #2
news:22***************************@news.microsoft. com...
Hello darrel,

In the codebehind for your ascx file, you'll have a line that says something like (forgive my VB)

public class MyUserControl Inherits UserControl

The inherits needs to be modified to be BaseLoadedControl (or whatever you
named your base class).


Argh. Duh! Missed the obvious.

Thanks, Matt...I think everything is working. I really appreciate the help.

-Darrel
Nov 19 '05 #3

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

Similar topics

16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
27
by: tuvok | last post by:
Is it correct that the virtual dtor of base gets called implicitly? Here's some code to demonstrate what I mean: Class B has a virtual destructor, so has class D which is derived from B. Deleting...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
1
by: Empire City | last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a ListItem in the cell. The display part works fine. I...
0
by: L Scott | last post by:
I've created a page ancestry (framework) for our application so that all pages in our app would have the same look and feel. To do this, I created several user controls (header, footer, menu,...
0
by: mathlec | last post by:
I have 2 WebApplication project (dummy and dummy2). The first is trying to load a UserControl compiled in the second. I've set up the application as follow: \_(Virtual directory) .:Modules:.
0
by: robert | last post by:
Hi all, I'm having a hard time resolving a namespace issue in my wsdl. Here's an element that explains my question, with the full wsdl below: <definitions name="MaragatoService"...
61
by: Sanders Kaufman | last post by:
I'm wondering if I'm doing this right, as far as using another class object as a PHP class property. class my_baseclass { var $Database; var $ErrorMessage; var $TableName; var $RecordSet;...
11
by: dolphin | last post by:
Hi All! I have a question that how to call a function just using a string. For example There is a .cpp file named a.cpp.There are some functions::fun1() fun2() fun3(). I have another fucntion...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
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 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.