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

  • Home
  • SEARCH
  • 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 7839229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:22:41+00:00 2026-06-02T15:22:41+00:00

I have a bit of a problem. I am currently makeing a webpage that

  • 0

I have a bit of a problem. I am currently makeing a webpage that has a few dropdown lists on each page. The purpose of the dropdown lists are to filter the information in a YUI datatable, aswell as eachother’s information, eg. a different location will have different commodities etc.

I have made a common function to read the option ID’s and values from the DB, but the information can be used in 3 ways. Currently, when the page loads I create a Asp:Placeholder that I load the Dropdown lists in. If the information is requested by Ajax to update a select box, I concatenate a HTML string server side and response.write it. But now my client has requested to have a lookup for if the list in the dropdown box is too long, which I am doing using a YUI modal panel and a YUI grid. I would still like to use the same data fetching subprocedure, but this time I would like to send the data back as a JSON string.

Currently I have boolean flags to signal whether its the pages initial load to create a placeholder, or an update load to make an HTML string, but I would rather like to pass the “information rendering/formatting” subprocedure as a parameter, this eleminating the need for several boolean flags.

My Code

    Public Shared Sub LoadCoop(ByRef PlaceHolder As Object, ByVal SearchCriteria As String, ByVal Database As String, ByVal InitialLoad As Boolean)
        Dim SqlConnection As New SqlConnection
        Dim SqlCommand As New SqlCommand
        Dim SqlParameter As New List(Of SqlParameter)
        Dim SqlReader As SqlDataReader = Nothing
        Dim FilterList As New List(Of FilterObject)
        Try
            SqlConnection = CreateDatabaseConnection(ConnectionString)
            AddSqlParameterToCollection(SqlParameter, "@SearchCriteria", SearchCriteria)
            AddSqlParameterToCollection(SqlParameter, "@Database", Database)
            SqlCommand = CreateSqlCommand("[proc_Dynamic_GetCoop]", SqlConnection, SqlParameter)
            SqlReader = SqlCommand.ExecuteReader
            If SqlReader.HasRows Then
                Do While SqlReader.Read
                    Dim TempFilterObject As FilterObject = New FilterObject
                    TempFilterObject.ID = SqlReader("PSCM_COOP_ID")
                    TempFilterObject.Description = SqlReader("PSCM_COOP_ID")
                    FilterList.Add(TempFilterObject)
                Loop
            End If
        If InitialLoad = True Then
            CreateHTMLSelectContainer(PlaceHolder, FilterList, "Coop")
        Else
            CreateHTMLSelectString(FilterList, "Coop")
        End If
    Catch ex As Exception
        HttpContext.Current.Response.Write("ERROR - An error occurred loading the co-op filter. Please contact the system administrators for assistance.")
    Finally
        If Not IsNothing(SqlReader) Then
            SqlReader.Close()
            SqlReader = Nothing
        End If
        If Not IsNothing(SqlCommand) Then
            SqlCommand.Dispose()
            SqlCommand = Nothing
        End If
        If Not IsNothing(SqlConnection) Then
            SqlConnection.Close()
            SqlConnection.Dispose()
            SqlConnection = Nothing
        End If
   End Try
End Sub

Public Shared Sub CreateHTMLSelectContainer(ByRef PlaceHolder As Object, ByVal FilterList As List(Of FilterObject), ByVal ID As String)
            Dim ReturnString As String = ""
            For Each Obj As FilterObject In FilterList
                ReturnString += "opening option tag" & Obj.Description & "closing option tag"
            Next

            Dim Container As New HtmlGenericControl("select")
            Container.ID = "ddl" & ID
            Container.Attributes.Add("class", "filtering_fields_select")
            Container.InnerHtml = ReturnString
            PlaceHolder.Controls.Add(Container)
            If FilterList.Count > 20 Then
                PlaceHolder.Controls.Add(New LiteralControl("lookup image goes here"))
            End If
        End Sub

        Public Shared Sub CreateHTMLSelectString(ByVal FilterList As List(Of FilterObject), ByVal ID As String)
            Dim ReturnString As String = "opening select tag"
            Dim Obj As FilterObject = Nothing
            For Each Obj In FilterList
                ReturnString += "opening option tag" & Obj.Description & "closing option tag"
            Next
            ReturnString += "closing select tag"
            If FilterList.Count > 20 Then
                ReturnString += "lookup image goes here"
            End If
            HttpContext.Current.Response.Write(ReturnString)
        End Sub


  • 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-02T15:22:43+00:00Added an answer on June 2, 2026 at 3:22 pm

    The delegate keyword lets you declare a variable type representing a function. This can then be used in a parameter declaration. The function is called by using variable_name.Invoke(parameters…).

    So something like this:

    ' declares data type representing one of the possible functions
    Public Delegate Sub CreateHTMLFunction(ByRef PlaceHolder As Object, ByVal FilterList As List(Of FilterObject), ByVal ID As String)
    
    Public Shared Sub LoadCoop(ByRef PlaceHolder As Object, ByVal SearchCriteria As String, ByVal Database As String, ByVal HTMLFunction As CreateHTMLFunction)
        ' last param is function to call 
        ' snip
        HTMLFunction.Invoke(PlaceHolder, FilterList, "Coop")
    End Sub
    
    Public Sub CreateHTMLSelectContainer(ByRef PlaceHolder As Object, ByVal FilterList As List(Of FilterObject), ByVal ID As String)
        ' blah blah
    End Sub
    
    Public Sub CreateHTMLSelectString(ByRef PlaceHolder As Object, ByVal FilterList As List(Of FilterObject), ByVal ID As String)
        ' blah blah
    End Sub
    

    When passing the parameter from the calling code, use AddressOf function_name:

            LoadCoop(..., ..., ..., Addressof CreateHTMLSelectContainer)
    

    But note all the functions to be passed in will need to have exactly the same parameters list – they must exactly match the definition of the delegate. So you would need to add the PlaceHolder parameter to the SelectString function even if it is not used.

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

Sidebar

Related Questions

I have a bit of problem when trying to validate my page as HTML5.
I have a bit of a strange problem. I have a controller that is
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I have a bit of a problem. I am trying to do the following
I have a bit of a problem building my project. I'm getting the bellow
I have a bit of a problem here. I have a third party ActiveX
I'm quite new to MediaWiki, and now I have a bit of a problem.
I have a bit of an architecture problem here. Say I have two tables,
I have a bit of a strange problem. I am trying to send in-app
I have a bit of a weird problem. I developed an app with MVC

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.