RadAjaxManager OnResponseEnd IE7 focus() not working

2 posts, 1 answers
  1. alsi
    alsi avatar
    33 posts
    Member since:
    Nov 2006

    Posted 02 Jun 2008 Link to this post

    Hi All!

    my problem is the following:
    I have many textboxes. They have TextChanged events attached. After ajax postback I use the following code snippets to give the focus of the actual (clicked) textbox

    my code :
     function focusActElement()
            if(actElement != '')
                 //if I use document.getElementById(actElement).select();
                 //works fine in IE7, too but I don't want to select the texts in the boxes

    in Page_Load i'm calling:
    public static void TrackFocusAfterAjaxPostbacks(Page page, RadAjaxManager radAjaxManager)
            // Insert startup script
            string scriptKey = "focusFunction";

            if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), scriptKey))
                page.ClientScript.RegisterStartupScript(page.GetType(), scriptKey, String.Format("focusActElement();"), true);

            radAjaxManager.ClientEvents.OnResponseEnd = "focusActElement";

    In FF works fine, but in IE7 just with id.select() functioning well and I don't like to select texts in the textboxes.

    can somebody help?
  2. Answer
    The Oracle
    The Oracle avatar
    46 posts
    Member since:
    Aug 2012

    Posted 01 Jul 2008 Link to this post

    Hey alsi,

    I found this script that might work for you:

    function clearSelection () {  
        if (document.selection)  
        else if (window.getSelection)  

    You can call it after you do your input.select().

    Here is the html of a simple form for you to test it (I modified it from the url provided above):

    <script type="text/javascript">  
    function onloader() {  
    function clearSelection () {  
    if (document.selection)  
    else if (window.getSelection)  
    <body > 
    <form action="" method="get" name="MyForm">  
    <input type="text" name="MyInput" 
    value="Hello World" > 
    <button onclick="onloader();">Set</button> 
    <button onclick="clearSelection();">Clear</button> 

Back to Top