Calling Dropdownlist by id in global functions page

42 Views Asked by At

I'm working on a project in asp.net with vb.net.

I had this function underneath in the file team.aspx.vb

Private Sub fillPFileRelationTypes()
        Dim intOfficeCategoryTypeId = fGetOfficeCategoryTypeId()
        ddl_RelationType.Items.Clear()
        ddl_RelationType.Items.Add("title","value")
        ddl_RelationType.Items.Add("title2","value2")
End Sub

It worked fint in combination with the frontend in file team.aspx. Which is no more than this:

<asp:DropDownList ID="ddl_PFileRelationType" runat="server">
            </asp:DropDownList>

But now I want to get all my functions in a global Functions.aspx.vb file. So it's not directly in the backend of the same page (as in team.aspx vs. team.aspx.vb) This means calling the dropdownlist by the id in the backend doesn't work anymore.

How can I call my dropdownlist with id="ddl_RelationType" in a file not related to the file where this one is declared?

I was thinking of the underneath but it's not entirely correct

Private Sub fillPFileRelationTypes()
            Dim intOfficeCategoryTypeId = fGetOfficeCategoryTypeId()
            Dim myInput As HtmlInputControl = CType(e.Item.FindControl("ddl_RelationType"), HtmlInputControl)
            myInput .Items.Clear()
            myInput .Items.Add("title","value")
            myInput .Items.Add("title2","value2")
    End Sub
0

There are 0 best solutions below