Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sharing a procedure from a UserControl

Status
Not open for further replies.

Caradog

Programmer
Jun 28, 2000
73
0
0
GB
I have a usercontrol attached to an aspx page (vb.net). The user control has a Public function set up as so:

Public Sub pdqmAddItem(ByVal intProdID As Int32)
lblTotal.Text = "add item " & intProdID
End Sub

In the code behind on the page which has the User Control on it, I want to be able to call the Functiob/Sub above to perform some actions. To do that I have added the following to the top of page:

Protected WithEvents ucPdqmBasketMini As pdqmBasketMini

Which defines the attached user control, then later on in the page an event which handles the onClick of a datalist to fire off:

ucPdqmBasketMini.pdqmAddItem(intProdID)

But, I get the error of:

Object reference not set to an instance of an object.

On the call of ucPdqmBasketMini.pdqmAddItem(intProdID).

How do I expose that procedure in the User Control to accept some data being passed thorugh it from another page??? Do I need to do a get/let on the procedure some how???

Confused and getting frustrated :(
 
In addition to the above, the procedure I am calling in teh Usewr Control is being called from *another* user control. Whem I call the same procedure from a aspx.vb page it works, its omly when I'm calling it from another control does it fall it over :(
 
If your procedure is part of UserControl2, but you are calling it from UserControl1, make sure you have a Register declarative in UserControl1 that points to UserControl2.

Hope that made sense!

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Ok I added this to top the aspx on UserControl1 in Register UserControl2

<%@ Register TagPrefix="uc1" TagName="pdqmBasketMini" Src="pdqmBasketMini.ascx" %>

But still same problem :(
 
A bit more here now, I dont think its a problem with the UC's as such, the UC which has the procedure I am calling in it fails if I make *any* attempt to populate a literal or label (or anything) to its paired ascx page!

Its as if the UC has no access to the screen even though all the controls have beem defined.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top