locked
Ajax combo box issue in ie 11 RRS feed

  • Question

  • User-878111659 posted

    I am facing an issue with ajax combo box in ie 11, where the intellisense feature is not working.

    In the below code which is executed in script resource.axd

    var userRange = document.selection.createRange();

    undefined value is being returned in ie 11 where as in ie 10 , it is returning the current length of the text in the combo box.

    This is leading to failure.

    Any suggestions/workarounds would be of great assitance.

    I used the latest available ajax components updated using nuget.

    Thanks in advance

    code:

    _getTextSelectionInfo: function (textBox, e) {

    var info = new Object();

    info.strategy = this._getTextSelectionStrategy();

    if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft) {

    var userRange = document.selection.createRange();

    info.selectionStart = 0;

    info.selectionEnd = textBox.value.length;

    while (userRange.moveStart('character', -1) != 0) {

    info.selectionStart++;

    }

    while (userRange.moveEnd('character', 1) != 0) {

    info.selectionEnd--;

    }

    }

    else if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C) {

    info.selectionStart = textBox.selectionStart;

    info.selectionEnd = textBox.selectionEnd;

    }

    info.typedCharacter = String.fromCharCode(e.charCode);

    info.textBoxValue = textBox.value;

    info.selectionPrefix = (info.textBoxValue.length >= info.selectionStart)

    ? info.textBoxValue.substring(0, info.selectionStart)

    : '';

    info.selectionText = (info.textBoxValue.length >= info.selectionEnd)

    ? info.textBoxValue.substring(info.selectionStart, info.selectionEnd)

    : '';

    info.selectionSuffix = (info.textBoxValue.length >= info.selectionEnd)

    ? info.textBoxValue.substring(info.selectionEnd, info.textBoxValue.length)

    : '';

    info.selectionTextFirst = info.selectionText.substring(0, 1);

    return info;

    },

    Tuesday, October 29, 2013 8:28 AM

Answers

  • User-417640953 posted

    var userRange = document.selection.createRange();

    undefined value is being returned in ie 11 where as in ie 10 , it is returning the current length of the text in the combo box.

    This is leading to failure.

    Hi k3627,

    I'm glad to you post the issue to asp.net forum.

    As we all known, document.selection support was removed in IE10 and replaced with window.getSelection.

    Each Ajax control and extender is associated with a Javascript file named as Behaviour.js . This file contains those functions which

    specify the behaviors of these controls and extenders. If we want to customize any behavior of these controls or extenders we can update the source code.

    you can update the source code to solve the issue using below link.

    if (window.getSelection) { // all browsers, except IE before version 9
        var selectionRange = window.getSelection();                                        
        return selectionRange.toString ());
    } 
    else {
        if (document.selection.type == 'None') {
           // alert ("No content is selected, or the selected content is not available!");
        }
        else {
            var textRange = document.selection.createRange ();
            return textRange.text;
        }
    }
    

    Hope this helps. Thanks.

     

    Best Regards!

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 31, 2013 3:38 AM
  • User555306248 posted

    IE 11 has been just launched with windows 8.1, so we'll have to wait for next release of AJAXControlToolkit, you can report issue here

    http://ajaxcontroltoolkit.codeplex.com/workitem/list/basic

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 1, 2013 12:15 AM

All replies

  • User-376018714 posted

    there is a breaking chage w.r.t selection in IE11.

    documemt.selection is replaced with window.getSelection

    check out the changes here:

    http://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.85).aspx

    Tuesday, October 29, 2013 1:50 PM
  • User-878111659 posted

    Thank you kashyapa.

    I am aware of the change made in IE 11.

    But the issue I am facing is ,this particular function is being called by ajax by default, where in I cannot change that. Kindly let me know if this can be solved. I am looking for a permament fix for ie11.

    Wednesday, October 30, 2013 1:05 AM
  • User-417640953 posted

    var userRange = document.selection.createRange();

    undefined value is being returned in ie 11 where as in ie 10 , it is returning the current length of the text in the combo box.

    This is leading to failure.

    Hi k3627,

    I'm glad to you post the issue to asp.net forum.

    As we all known, document.selection support was removed in IE10 and replaced with window.getSelection.

    Each Ajax control and extender is associated with a Javascript file named as Behaviour.js . This file contains those functions which

    specify the behaviors of these controls and extenders. If we want to customize any behavior of these controls or extenders we can update the source code.

    you can update the source code to solve the issue using below link.

    if (window.getSelection) { // all browsers, except IE before version 9
        var selectionRange = window.getSelection();                                        
        return selectionRange.toString ());
    } 
    else {
        if (document.selection.type == 'None') {
           // alert ("No content is selected, or the selected content is not available!");
        }
        else {
            var textRange = document.selection.createRange ();
            return textRange.text;
        }
    }
    

    Hope this helps. Thanks.

     

    Best Regards!

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 31, 2013 3:38 AM
  • User555306248 posted

    IE 11 has been just launched with windows 8.1, so we'll have to wait for next release of AJAXControlToolkit, you can report issue here

    http://ajaxcontroltoolkit.codeplex.com/workitem/list/basic

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 1, 2013 12:15 AM
  • User-230512220 posted

    Hi Fuxiang,

    updating source code  means??

    you mean behaviour.js??? if so how??

    please help me in understanding this..??

    Thursday, December 19, 2013 5:51 AM
  • User-878111659 posted

    After some trial and error I found the solution for the problem. I modified the below code combobox.pre.js file in source code and used the custom build dll in my application . Hope it may be use full to others.

    _getTextSelectionInfo:

    function (textBox, e) {

    // returns a helper object with information about textbox selection

    var info = new Object();

    // strategy

            info.strategy =

    this._getTextSelectionStrategy();

    // selectionStart & selectionEnd

    if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft) {

                info.selectionStart = 0;

                info.selectionEnd = textBox.value.length;

    var userRange;

    if (window.getSelection) { // all browsers, except IE before version 9

    //Modified code start for IE 11

                    info.selectionStart = textBox.selectionStart;

                    info.selectionEnd = textBox.selectionEnd;        

    //Modified code end for IE 11

                }

    else {  

                    userRange = document.selection.createRange();

    while (userRange.moveStart('character', -1) != 0) {

                        info.selectionStart++;

                    }

    while (userRange.moveEnd('character', 1) != 0) {

                        info.selectionEnd--;

                    }               

                } 

            }

    else if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C) {

                info.selectionStart = textBox.selectionStart;

                info.selectionEnd = textBox.selectionEnd;

            }

    // typedCharacter, textBoxValue, selectionPrefix, selectionSuffix, selectionTextFirst

            info.typedCharacter = String.fromCharCode(e.charCode);

            info.textBoxValue = textBox.value;

            info.selectionPrefix = (info.textBoxValue.length >= info.selectionStart)

                ? info.textBoxValue.substring(0, info.selectionStart)     :'';

            info.selectionText = (info.textBoxValue.length >= info.selectionEnd)

                ? info.textBoxValue.substring(info.selectionStart, info.selectionEnd)    : '';

            info.selectionSuffix = (info.textBoxValue.length >= info.selectionEnd)

    ? info.textBoxValue.substring(info.selectionEnd, info.textBoxValue.length)    :'';

            info.selectionTextFirst = info.selectionText.substring(0, 1);return info;

        },

    Monday, December 23, 2013 1:00 AM