473,325 Members | 2,308 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,325 software developers and data experts.

stuck: I cant reach usercontrol's class ..

in asp.net
If I have a web usercontrol WUC with code behind Class CLASSWUC
and I have a web page that loads the control

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
MANAGEGENERAL = LoadControl("WUC.ascx")
MyPlaceholder.Controls.Add(MANAGEGENERAL)
InitializeComponent()
End Sub

And if in CLASSWUC I have a finction that displays a value on the label of
WUC like

Sub DisplayValue(value as String)
Mylabel.text=value
End Sub

QUESTION:

What code shoud I have in my web page to be able to call DisplayValue so as
to display a value in the label.

I current get the message:
Line 1122: Dim stuff As New
PORTAL.ManageGeneralNameSpace.CLASSWUC
Line 1123: stuff.DisplayValue("test")
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Thanks

Nov 19 '05 #1
2 1197
private manageGeneral as ClassWuc
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
manageGeneral = ctype(LoadControl("WUC.ascx"), ClassWuc)
manageGeneral.DisplayValue("heh")
MyPlaceholder.Controls.Add(manageGeneral )
InitializeComponent()
End Sub

you cold call displayValue in page_load as well...the trick is that
Page.LoadControl returns a System.Web.UI.Control...which your class ClassWuc
inherits from...however, in order to get DisplayValue (which
System.Web.UI.control doesn't have) you need to cast the returned type to
the appropriate ClassWuc class

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Support" <Re****************@mail.oci.state.ga.us> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
in asp.net
If I have a web usercontrol WUC with code behind Class CLASSWUC
and I have a web page that loads the control

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
MANAGEGENERAL = LoadControl("WUC.ascx")
MyPlaceholder.Controls.Add(MANAGEGENERAL)
InitializeComponent()
End Sub

And if in CLASSWUC I have a finction that displays a value on the label of
WUC like

Sub DisplayValue(value as String)
Mylabel.text=value
End Sub

QUESTION:

What code shoud I have in my web page to be able to call DisplayValue so as to display a value in the label.

I current get the message:
Line 1122: Dim stuff As New
PORTAL.ManageGeneralNameSpace.CLASSWUC
Line 1123: stuff.DisplayValue("test")
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Thanks

Nov 19 '05 #2
THANKS!!!
saved from desperation..

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
private manageGeneral as ClassWuc
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
manageGeneral = ctype(LoadControl("WUC.ascx"), ClassWuc)
manageGeneral.DisplayValue("heh")
MyPlaceholder.Controls.Add(manageGeneral )
InitializeComponent()
End Sub

you cold call displayValue in page_load as well...the trick is that
Page.LoadControl returns a System.Web.UI.Control...which your class
ClassWuc
inherits from...however, in order to get DisplayValue (which
System.Web.UI.control doesn't have) you need to cast the returned type to
the appropriate ClassWuc class

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Support" <Re****************@mail.oci.state.ga.us> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
in asp.net
If I have a web usercontrol WUC with code behind Class CLASSWUC
and I have a web page that loads the control

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
MANAGEGENERAL = LoadControl("WUC.ascx")
MyPlaceholder.Controls.Add(MANAGEGENERAL)
InitializeComponent()
End Sub

And if in CLASSWUC I have a finction that displays a value on the label
of
WUC like

Sub DisplayValue(value as String)
Mylabel.text=value
End Sub

QUESTION:

What code shoud I have in my web page to be able to call DisplayValue so

as
to display a value in the label.

I current get the message:
Line 1122: Dim stuff As New
PORTAL.ManageGeneralNameSpace.CLASSWUC
Line 1123: stuff.DisplayValue("test")
Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

Thanks


Nov 19 '05 #3

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

Similar topics

1
by: jralford | last post by:
Hi, Another question from a C# newbie: I have a usercontrol class that includes a customized control. Now, if I create an instance of the class, and click on it, a click event is raised for the...
2
by: Micke Palm | last post by:
Hi! I have set up one aspx page and I using a few usercontrols to this page. The treestructure is like below... aspx / \ uCtrl1 uCtrl2 \ uCtrl3
4
by: Darrel | last post by:
I'm really stuck on the concept of using public variables to pass information between usercontrols. I'm pretty sure I'm just flubbing up the syntax. This is what I want: page usercontrol 1 -...
0
by: N. Demos | last post by:
Hello, I have a custom usercontrol, of which I have two instances of in my aspx page. Both the usercontrol and page have codebehind. In the page codebehind, I want a member variable for each...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
0
by: JR | last post by:
Hi, i found a user control on the net see code below it is part of VSEssential but I like the coolProgressBar. Zo I want to use it into my program and I always get the error that it can't find...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
10
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.