Call a sub from 1 usercontrol to another.

Discussion in 'ASP .Net Web Controls' started by Jay, Mar 10, 2005.

  1. Jay

    Jay Guest

    Guys, I'm stuck!!!

    I have two usercontrosl, in UC2 I had a public sub which I want to call
    from UC1. Both UC's are on the same aspx page.

    In UC1 I have teh following line at the top of the ascx:

    Protected WithEvents ucPdqmBasketMini As pdqmBasketMini

    IN UC2 the sub looks like:

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

    The lblTotal label is member of the .aspx/vb page.

    When I call the Sub from UC1 with the following:

    ucPdqmBasketMini.pdqmAddItem(intProdID)

    I get the error:

    Object reference not set to an instance of an object.

    So thinking UC1 cannot see UC2 I added the following declaration in the
    ascx of UC1:

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

    Still no joy. Any ideas what I am doing wrong?
    Jay, Mar 10, 2005
    #1
    1. Advertising

  2. Jay

    Jay Guest

    In addition, when I call the sub the aspx.vb which has both UC's
    registered, there's no problem at all.
    Jay, Mar 10, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Burke
    Replies:
    3
    Views:
    381
    Kathy Burke
    Nov 24, 2003
  2. nail
    Replies:
    0
    Views:
    1,519
  3. Ben
    Replies:
    2
    Views:
    853
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,934
    Lawrence D'Oliveiro
    May 20, 2011
  5. Replies:
    1
    Views:
    165
Loading...

Share This Page