Click here to Skip to main content
15,921,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using below script for editable drop down list and it is working fine with without master page but when i apply this with master page it is not working. can anybody help on this.

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

<script type="text/javascript">
      (function ($) {

          $.widget("custom.combobox", {
              _create: function () {
                  this.wrapper = $("<span>")


              _createAutocomplete: function () {
                  var selected = this.element.children(":selected"),
            value = selected.val() ? selected.text() : "";

                  this.input = $("<input>")
            .attr("title", "")
            .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
                delay: 0,
                minLength: 0,
                source: $.proxy(this, "_source")
                tooltipClass: "ui-state-highlight"

                  this._on(this.input, {
                      autocompleteselect: function (event, ui) {
                          ui.item.option.selected = true;
                          this._trigger("select", event, {
                              item: ui.item.option

                      autocompletechange: "_removeIfInvalid"

              _createShowAllButton: function () {
                  var input = this.input,
            wasOpen = false;

            .attr("tabIndex", -1)
            .attr("title", "Show All Items")
                icons: {
                    primary: "ui-icon-triangle-1-s"

                text: false
            .addClass("custom-combobox-toggle ui-corner-right")
            .mousedown(function () {
                wasOpen = input.autocomplete("widget").is(":visible");
            .click(function () {

                // Close if already visible
                if (wasOpen) {

                // Pass empty string as value to search for, displaying all results
                input.autocomplete("search", "");

              _source: function (request, response) {
                  var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                  response(this.element.children("option").map(function () {
                      var text = $(this).text();
                      if (this.value && (!request.term || matcher.test(text)))
                          return {
                              label: text,
                              value: text,
                              option: this

              _removeIfInvalid: function (event, ui) {

                  // Selected an item, nothing to do
                  if (ui.item) {

                  // Search for a match (case-insensitive)
                  var value = this.input.val(),
            valueLowerCase = value.toLowerCase(),
            valid = false;
                  this.element.children("option").each(function () {
                      if ($(this).text().toLowerCase() === valueLowerCase) {
                          this.selected = valid = true;
                          return false;

                  // Found a match, nothing to do
                  if (valid) {

                  // Remove invalid value
            .attr("title", value + " didn't match any item")
                  this._delay(function () {
                      this.input.tooltip("close").attr("title", "");
                  }, 2500);
                  this.input.autocomplete("instance").term = "";

              _destroy: function () {

      $(function () {
          $("#toggle").click(function () {

What I have tried:

i have tried to get control value in master page as below:
var combobox = document.getElementById('<%= this.ContentPlaceHolder1.FindControl("combobox").ClientID %>');

but it is not work
Updated 23-Aug-16 0:24am
F-ES Sitecore 22-Aug-16 11:04am    
Is that script on the master page or the content page? Is combobox and toggle on the master page or content page? The solution is fairly straight forward but it depends where everything is.
Sainiharish 23-Aug-16 1:59am    
i have check the script on master page and content page too but not working. drop down on content page, In this situation where i have to put script master page or content page and what i have to change in jquery
F-ES Sitecore 23-Aug-16 4:02am    
That link covers script on master page accessing components on content page and vice versa. Also master accessing controls on the master page (the code for that is the same for the content page), so just look how it is done in the link and do the same. It's still unclear where everything is so it's hard to give you a specific answer.
ZurdoDev 22-Aug-16 11:39am    
The client id changes when you put it into a master page. Just do a little bit of debugging and you'll find out exactly what is happening.
Sainiharish 23-Aug-16 1:51am    
i have check the script on master page and content page too but not working. drop down on content page, In this situation where i have to put script master page or content page and what i have to change in jquery

1 solution

Try to move your codes within the ContentHead of your Content page and then do something like this for referencing the server control:

$(function () {
	  var $cb = $("#<%=combobox.ClientID%>");
          $("#toggle").click(function () {

If your toggle element is a server control then you may also need to change the code for accessing it like this:

$("<%=toggle.ClientID%>").click(function () {

If you are still getting error after applying this changes, then use the browser debugger tools to get the error details.
Share this answer
Sainiharish 24-Aug-16 6:47am    
Thanks dear my issue is resolved by this thanks a lot
Vincent Maverick Durano 24-Aug-16 6:56am    
glad to be of help. :)
Sainiharish 24-Aug-16 7:40am    
But there is new problem i m facing, when i select a item from this editable drop down and if i bound s event code behind for onselectedindexchanged which is not executed. AutoPostback also "True". what i have to do. thanks in advance
Vincent Maverick Durano 24-Aug-16 7:47am    
I would suggest you to create a separate thread for your new issue. Don't forget to provide the details.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900