tags:

views:

20

answers:

2

I have a class in a separate file (stripped out a lot for simplicity)

public class navigation
{
    // Adds to menu
    public static void addMenuToList(ListView parent)
    {                
        parent.Items.Add(newItem);
    }
}

Where parent is a control on my .net page:

<asp:ListBox SelectionMode="Single" Rows="8" id="parent" runat="server" CssClass="tbox widebox">

How do I pass the control to the function so it can be accessed?

navigation.addMenuToList(parent);

This doesn't seem to work. Am I going about it wrong?

+2  A: 

Your method accepts a ListView and your object is of type ListBox. Perhaps the "not working" thingy stems from this difference?

In general, there's nothing wrong in passing your control to another method, but the types must match of course.

Abel
A: 

Doh!

Pass ListBox not ListView then it works fine :)

Sorry for wasting everyones time.

Tom Gullen
Np about the time, I think I beat you to it with a few seconds ;)
Abel