Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:49:04+00:00 2026-06-13T03:49:04+00:00

I have an asp.net web page which is giving me some problems. I developed

  • 0

I have an asp.net web page which is giving me some problems. I developed the following classes to generate search filters for the page. The search process is not important as it already works. I want to dynamically generate the search filters.

Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports MEI.SPDocuments.Type


Public Class SearchFilter
    Private WithEvents _genreDropDown As DropDownList
    Private WithEvents _subGenreDropDown As DropDownList
    Private WithEvents _txtValue As TextBox
    Private _txtBoxAutoCompleteExtender As AjaxControlToolkit.AutoCompleteExtender
    Private _filterGenres As Collection(Of String)
    Private _programSubGenres() As String = {"Program ID,GetPrograms", "Territory ID,GetTerritories", _
                                             "Rep Name,GetRepNames", "District ID,GetDistricts", "DM Name,GetDMNames", "Region ID,GetRegions", _
                                             "RM Name,GetRMNames", "Speaker Counter,GetSpeaker", "Vedor ID,GetVendors", "Vendor Name,GetVendorName", _
                                             "Date Range,", "City,", "State,", "Pay To,", "Expense Range,", "PIF ID,GetPifs"}
    Private _speakerSubGenres() As String = {"Speaker Counter,GetSpeaker", "Speaker Last Name,GetSpeakerLNames", "Speaker First Name,GetSpeakerFNames"}
    Private _expenseSubGenres() As String = {"Expense Counter,GetExpenses"}
    Private _vendorSubGenres() As String = {"Vendor ID,GetVendors", "Vendor Name,GetVendorName"}
    Private _trackSubGenres() As String = {"Track Number,GetTracks", "HCP First Name,GetHCPFName", "HCP Last NameGetHCPLName"}

    Public Sub New(ByVal company As CompanyCode, ByVal year As DocumentYearCode)
        _filterGenres = New Collection(Of String)

    _txtValue = New TextBox
    _txtValue.ID = Guid.NewGuid.ToString

    _txtBoxAutoCompleteExtender = New AjaxControlToolkit.AutoCompleteExtender
    With _txtBoxAutoCompleteExtender
        .ID = "AC__" + _txtValue.ID
        .MinimumPrefixLength = 1
        .EnableCaching = False
        .ServicePath = "~/AutoComplete.asmx"
        .ServiceMethod = "PlaceHolder"
        .TargetControlID = _txtValue.ID
        .CompletionListCssClass = "CompletionList"
        .CompletionListHighlightedItemCssClass = "ItemHighlighted"
        .CompletionListItemCssClass = "ListItem"
        .DelimiterCharacters = ""
        .Enabled = True
    End With


    Select Case company
        Case CompanyCode.AbbottAnimalHealth, CompanyCode.AbbottDiabetesCare, CompanyCode.AbbottDiagnosticsDivision, CompanyCode.AbbottMedicalOptics, CompanyCode.AbbottMolecular, _
            CompanyCode.AbbottPointOfCare, CompanyCode.AbbottVascular, CompanyCode.Corporate, CompanyCode.DivAbbottNutrition, CompanyCode.EstablishedProductsDivision, _
            CompanyCode.GlobalPharmaceuticalResearchAndDevelopment, CompanyCode.GlobalStrategicMarketingAndServices, CompanyCode.PharmaseuticalProductsGroup, _
            CompanyCode.ProprietaryPharmaceuticalsDivision, CompanyCode.RegulatoryAffairsPPG
            _filterGenres.Add("Div Docs")
        Case Else
            _filterGenres.Add("Program")
            _filterGenres.Add("Speaker")
            _filterGenres.Add("Expense")
            _filterGenres.Add("Vendor")
    End Select
    _genreDropDown = New DropDownList
    _genreDropDown.AutoPostBack = True
    _genreDropDown.Attributes.Add("runat", "server")
    AddHandler _genreDropDown.SelectedIndexChanged, AddressOf _genreDropDown_ItemChanged

    _subGenreDropDown = New DropDownList
    _subGenreDropDown.AutoPostBack = True
    _subGenreDropDown.Attributes.Add("runat", "server")
    AddHandler _subGenreDropDown.SelectedIndexChanged, AddressOf _subGenreDropDown_ItemChanged
    PopulateDDls()
End Sub

Private Sub PopulateDDls()
    _genreDropDown.Items.Add("")
    For Each s As String In _filterGenres
        _genreDropDown.Items.Add(s)
    Next
End Sub

Private Sub _genreDropDown_ItemChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    _subGenreDropDown.Items.Clear()
    _subGenreDropDown.Items.Add("")
    Select Case _genreDropDown.SelectedItem.ToString
        Case "Program"
            For Each s As String In _programSubGenres
                Dim li As New ListItem(s.Split(CChar(","))(0), s.Split(CChar(","))(1))

                _subGenreDropDown.Items.Add(li)
            Next
        Case "Speaker"
            For Each s As String In _speakerSubGenres
                Dim li As New ListItem(s.Split(CChar(","))(0), s.Split(CChar(","))(1))

                _subGenreDropDown.Items.Add(li)
            Next
        Case "Expense"
            For Each s As String In _expenseSubGenres
                Dim li As New ListItem(s.Split(CChar(","))(0), s.Split(CChar(","))(1))

                _subGenreDropDown.Items.Add(li)
            Next
        Case "Vendor"
            For Each s As String In _vendorSubGenres
                Dim li As New ListItem(s.Split(CChar(","))(0), s.Split(CChar(","))(1))

                _subGenreDropDown.Items.Add(li)
            Next
        Case "Div Docs"
            For Each s As String In _trackSubGenres
                Dim li As New ListItem(s.Split(CChar(","))(0), s.Split(CChar(","))(1))

                _subGenreDropDown.Items.Add(li)
            Next
    End Select
End Sub

Private Sub _subGenreDropDown_ItemChanged(ByVal Sender As Object, ByVal e As System.EventArgs)
    _txtBoxAutoCompleteExtender.ServiceMethod = _subGenreDropDown.SelectedValue.ToString
    If _subGenreDropDown.SelectedValue.ToString = String.Empty Then _txtBoxAutoCompleteExtender.ServiceMethod = "PlaceHolder"
End Sub

Public Function createMyTableRow() As HtmlTableRow
    Dim myRow As New HtmlTableRow

    myRow.Cells.Add(New HtmlTableCell())
    myRow.Cells.Add(New HtmlTableCell())
    myRow.Cells.Add(New HtmlTableCell())

    myRow.Cells(0).Controls.Add(_genreDropDown)
    myRow.Cells(1).Controls.Add(_subGenreDropDown)
    myRow.Cells(2).Controls.Add(_txtValue)
    myRow.Cells(2).Controls.Add(_txtBoxAutoCompleteExtender)

    Return myRow
End Function

Private Sub newAutoCompleteExtender(ByVal genre As String)
    If _txtValue.Parent.Controls.Count = 2 Then
        _txtValue.Parent.Controls.RemoveAt(1)
    End If


    _txtValue.Parent.Controls.Add(_txtBoxAutoCompleteExtender)
End Sub

End Class


Public Class SearchFilterGroup

Private _searchFilterCollection As Collection(Of SearchFilter)
Private _tableContainer As HtmlTable
Private _company As CompanyCode
Private _year As DocumentYearCode
Public WithEvents _addFilterButton As New Button

Public Sub New(ByVal company As CompanyCode, ByVal year As DocumentYearCode)
    _searchFilterCollection = New Collection(Of SearchFilter)
    _tableContainer = New HtmlTable
    _company = company
    _year = year


    _addFilterButton.Text = "Add Filter"
    _addFilterButton.Attributes.Add("runat", "server")
    _addFilterButton.ID = "btnAddFilter"
    AddHandler _addFilterButton.Click, AddressOf _addFilterButton_Click
End Sub

Public Sub _addFilterButton_Click(ByVal Sender As Object, ByVal e As System.EventArgs)
    _searchFilterCollection.Add(New SearchFilter(_company, _year))
    _tableContainer.Rows.Add(_searchFilterCollection(_searchFilterCollection.Count - 1).createMyTableRow)
End Sub

Public Function table() As HtmlTable
    _tableContainer.Rows.Add(New HtmlTableRow)
    _tableContainer.Rows(0).Cells.Add(New HtmlTableCell)
    _tableContainer.Rows(0).Cells(0).ColSpan = 3

    _tableContainer.Rows(0).Cells(0).Controls.Add(_addFilterButton)
    _addFilterButton_Click(Nothing, Nothing)
    _addFilterButton_Click(Nothing, Nothing)

    Return _tableContainer
End Function
End Class

I am having problems devising a way to persist the generate controls. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:49:06+00:00Added an answer on June 13, 2026 at 3:49 am

    Basically, for task which you do is better to create custom server control. In ASP.NET exist CompositeControl class which simplifies developing your own server controls which for example should include some other server controls (like panels, texboxes and etc) as children.

    A very good link to start with creating your own server controls is Dino Esposito article: A Crash Course on ASP.NET Control Development: Building Composite Controls

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Web application (ASP.NET) which displays in some page links to miscellaneous
I have an ASP.Net web page, which uses a Master Page template. The page
I have a ASP.NET web application which has more than 100 pages. Each page
I have a ASP.NET (C#) web page which utilizes a VB class library. The
I have a ASP.NET (C#) web page in which I want to enumerate a
I have a ASP.NET 1.1 web application page which is built with .net framework
I have an asp.net web page which interacts with a SQL Server database, grabs
I have an ASP.NET MVC 3 (Razor) Web Application, with a particular page which
I have a ASP.NET web page which contains a table of check boxes and
I have an asp.net web page written in C#. Using some javascript I popup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.