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 7871781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:00:40+00:00 2026-06-03T02:00:40+00:00

I am attempting to create a ASP .Net (VB.Net) custom control for an auto-complete

  • 0

I am attempting to create a ASP .Net (VB.Net) custom control for an auto-complete drop down that uses jQuery auto-complete.

The basic flow is the consumer of the control will set some properties (such as the data source) which will then be injected as javascript to initialize the autocomplete.

There are a lot of pieces involved so i may have missed posting some of the code, please comment if you think something is missing and i will add it.

the consumer’s code behind (PreInit event):

myDropDown.DataCallback = "testFunc";

the DataCallback property in the control:

Public Property DataCallback As String

the options object creation and javascript injection in the control code behind (PreRender event):

Dim _serializer As New JavaScriptSerializer()
Dim optionsObject As New Dictionary(Of String, Object)
optionsObject.Add("source", DataCallback)
Dim optionsJSON = _serializer.Serialize(optionsObject)

Dim initializeScript = String.Format("initialize('{0}', {1});", ClientID, optionsJSON)
Attributes.Add("onfocusin", initializeScript)

and finally, the javascript:

var initialize = function (controlID, options) {
    if (options) {
        $('#' + controlID).autocomplete(options);
    }

    // remove the blur event handler that called this initialize function
    $('#' + controlID).removeAttr('onfocusin');
};

when i debug into the initialize function, i see options has one property, source, with the string "testFunc" as it’s value. what i need is for source‘s value to be testFunc (not as a string) so it can be executed as a callback in autocomplete instead of autocomplete thinking it is a URL.

  • 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-03T02:00:41+00:00Added an answer on June 3, 2026 at 2:00 am

    The easiest way to correct this is with a bit of pattern recognition. Your problem arises because the string property is being serialized as a string and enclosed in quotation marks. You instead want it to represent an object reference, which means getting rid of those quotes. To remove the quotation marks, there’s a simple regular expression you can apply to the serialized object string:

    Dim optionsJSON = _serializer.Serialize(optionsObject)
    optionsJSON = Regex.Replace(optionsJSON , "(?<=""source"":)""(.+?)""", "$1")
    

    What this will do is look for the quoted string preceded by the text "source": and capture what’s inside to capture group #1. It will then replace that entire match with the inner text, effectively removing the quotes from either side of the callback function’s name.

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

Sidebar

Related Questions

I am attempting to create a custom server control CollapsablePanel that extends ASP.net's Panel.
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create my own custom Autocomplete style dropdown control in c#
I'm attempting to create themeing system for my asp.net mvc application. I was able
I am attempting to create a clickable piechart in ASP.NET 2.0 with C# using
I'm attempting to eliminate the duplication accross two ASP.NET web projects that use exactly
I am attempting to manipulate an asp.net MVC2 view variable in Jquery... (function ()
I'm attempting to implement complete search functionality in my ASP.NET MVC (C#, Linq-to-Sql) website.
I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The

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.