Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > stuck: I cant reach usercontrol's class ..

Reply
Thread Tools

stuck: I cant reach usercontrol's class ..

 
 
Support
Guest
Posts: n/a
 
      03-24-2005
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


 
Reply With Quote
 
 
 
 
Louis Yeung
Guest
Posts: n/a
 
      04-01-2005
Well, I am also green in this usercontrol world. I believe that you should be
able to do so in Page_Init because the instance variable MANAGEGENERAL should
be of class CLASSWUC. Therefore, MANAGEGENERAL.DisplayValue("xxx") is valid.

I do not think "new CLASSWUC" is a good idea because this is a user control
class. It is normally created via "LoadControl". I believe you want to get
back the created CLASSWUC instance rather than using a new instance.

...Louis

"Support" wrote:

> 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
stuck: I cant reach usercontrol's class .. Support ASP .Net 2 03-24-2005 04:35 PM
stuck: I cant reach usercontrol's class .. Support ASP .Net Web Controls 0 03-24-2005 03:42 PM
Cant reach php.net Picture Dots Computer Support 8 02-09-2004 03:40 AM
Why cant I reach PHP.net? Picture Dots Computer Support 12 02-09-2004 03:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57