This is a migrated thread and some comments may be shown as answers.

SelectionOnFocus="SelectAll" issue urgent.

4 Answers 101 Views
Input
This is a migrated thread and some comments may be shown as answers.
shunman
Top achievements
Rank 1
shunman asked on 10 Apr 2012, 02:26 AM
Hello  Telerik team.

I need help aboout we have a TextBox property issue.

We are using some textbox controls in the RadWindow control.

I set the SelectionOnFocus="SelectAll" and TextMode="MultiLine" properties on the textbox.

If close the window as soon as focus on textbox,  it raise telerik script error.

i'm attaching source code, and screen shot.
source code link is here: http://www.mediafire.com/?a2aebu7279wggus

PS. I have tested telerik version "2012.2.406.40" and "2012.1.320.40"
It still have problem both.

4 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 11 Apr 2012, 03:08 PM
Hello shunman,

You could override the _applySelection function like this:

Telerik.Web.UI.RadInputControl.prototype._applySelection = function()
    {
        if (!this._isInVisibleContainer(this._textBoxElement))
        {
            return;
        }
 
        var control = this;
 
        if ((Sys.Browser.agent == Sys.Browser.Opera) || !document.selection)
        {
            this._textBoxElement.selectionStart = control._selectionStart;
            this._textBoxElement.selectionEnd = control._selectionEnd;
            return;
        }
 
        try
        {
            this._textBoxElement.select();
 
            sel = document.selection.createRange();
            sel.collapse();
            sel.moveStart('character', this._selectionStart);
            sel.collapse();
            sel.moveEnd('character', this._selectionEnd - this._selectionStart);
            sel.select();
        }
        catch (e)
        {
            var context = this;
            window.setTimeout(function ()
            {
 try
        {
                document.body.focus();
 
                context._textBoxElement.select();
                sel = document.selection.createRange();
                sel.collapse();
                sel.moveStart('character', context._selectionStart);
                sel.collapse();
                sel.moveEnd('character', context._selectionEnd - context._selectionStart);
                sel.select();
            }catch (e)
        {}
}, 1);
        }
    }


Kind regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shunman
Top achievements
Rank 1
answered on 12 Apr 2012, 01:00 AM
Hello telerik.

thank you for reply.

the code is work fine.

Is there a plan for including this code snippet to next version?
0
shunman
Top achievements
Rank 1
answered on 12 Apr 2012, 03:32 AM
Hello.

I had tried some snippet to some screens.

I am facing same problem.

I  include code snippet to each screen's .js file like below.

function ddd()
{
..........
}

Telerik.Web.UI.RadInputControl.prototype._applySelection = function()
{
....................
}

a few screens doesn't not overrided function from .js file.
it still executed by Telerik.Web.UI.WebResource.axd

could you some advise me for this matter?
0
Vasil
Telerik team
answered on 16 Apr 2012, 11:11 AM
Hello shunman,

Use the OnLoad ClientEvent of the first RadInputControl in your form, to execute your code that overrides the _applySelection. This way you will be sure that the code is always executed and the function get's overridden before it is required.

A fix will be included in the next version of the controls, but the fix may not be exactly the same as the workaround, we will perform some additional test before and after changing the code.

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Input
Asked by
shunman
Top achievements
Rank 1
Answers by
Vasil
Telerik team
shunman
Top achievements
Rank 1
Share this question
or