G
Guest
Hello All,
I have a UserControl wwhich consists of one Label and one DropDownList
control. I have written a Public methofd to allow me to set the Label's Text
property and populate the dropdownlist with listitems. Here's the code:
Public Sub PopulateDropDownList(ByVal ListCaption As String, ByVal
ListItems As XmlNode)
Label1.Text = ListCaption
Dim Items As XmlNodeList = ListItems.SelectNodes("Items/Item")
For Each Item As XmlNode In Items
Dim li As New ListItem
li.Value = Item.Attributes("id").Value
li.Text = Item.Attributes("value").Value
DropDownList1.Items.Add(li)
Next
End Sub
I would like to call this from my webform by writing:
Dim UControl As UserControl =
CType(LoadControl("UserControls/AugmentedDropDownList.ascx"), UserControl)
UControl.PopulateDropDownList("Recipient's Name:", RecipientNamesNode)
This doesn't work. The PopulateDropDownList doesn't appear in the
intellisense list. What appears in the list are the properties and methids
of a UserControl (as anyone would expect).
How can I do this? I know that it's possible; I just can't think of a way
how.
Does anyone know of a good online reference for coding UserControls?
TIA,
I have a UserControl wwhich consists of one Label and one DropDownList
control. I have written a Public methofd to allow me to set the Label's Text
property and populate the dropdownlist with listitems. Here's the code:
Public Sub PopulateDropDownList(ByVal ListCaption As String, ByVal
ListItems As XmlNode)
Label1.Text = ListCaption
Dim Items As XmlNodeList = ListItems.SelectNodes("Items/Item")
For Each Item As XmlNode In Items
Dim li As New ListItem
li.Value = Item.Attributes("id").Value
li.Text = Item.Attributes("value").Value
DropDownList1.Items.Add(li)
Next
End Sub
I would like to call this from my webform by writing:
Dim UControl As UserControl =
CType(LoadControl("UserControls/AugmentedDropDownList.ascx"), UserControl)
UControl.PopulateDropDownList("Recipient's Name:", RecipientNamesNode)
This doesn't work. The PopulateDropDownList doesn't appear in the
intellisense list. What appears in the list are the properties and methids
of a UserControl (as anyone would expect).
How can I do this? I know that it's possible; I just can't think of a way
how.
Does anyone know of a good online reference for coding UserControls?
TIA,