Cannot Refresh Parent TextBox On Close

3 posts, 0 answers
  1. Lynn
    Lynn avatar
    186 posts
    Member since:
    Sep 2006

    Posted 02 Nov 2009 Link to this post

    I have a RadTextBox control on a page where the user must enter a new value unique to the database contents (such as with a new user "Screen Name").  I have put a a button on the page next to the RadTextBox that opens a RadWindow so the user can "try" different values until they get a value that is unique (view attached graphic file RadWindow1).  When the user finds a unique value, they can click on a "submit" button to post the value to the RadTextBox on the parent page.

    This is all working just fine -- except the displayed value in the RadTextBox on the parent window never shows the updated/changed value.  The RadTextBox does actually contain the new value, it just is never displayed.

    For example...the user keys "Bill" into the RadTextBox, then clicks on the "Check" button to display the RadWindow to test the value against the database. Let's suppose "Bill" has to be changed to "Bill123" to get a unique value.  The user would then click on the "Submit" button in the RadWindow to close the window and store the "Bill123" value in the RadTextBox known as "Screen Name".

    The javascript being executed when the RadWindow is closed is shown in the graphic file "radwindow2" below.

    I have found another forum entry that exactly describes this problem at http://forums.asp.net/p/1440589/3261260.aspx .  Apparently, this is somewhat of a known problem with the RadWndow and the RadTextBox when used in this scenario.

    Is there any way to get the RadTextBox to display the newly updated value?  If I click the mouse in the Screen Name field after it has been updated, the new value will "magically" display (just as described in the forum link specified above).

    Thanks in advance if anyone can tell me how to correct this behavior!

    Lynn

    P.S. - I apologize for the somewhat confusing variable/field names used in the javascript code.  I have been using your demo of the RadWindow control -- "Returning Values from a Dialog" as a starting point and then modifying in "baby steps" until getting what I need.
    So the variable names are a combination of those from the demo and from my web page.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Nov 2009 Link to this post

    Hi Lynn,

    I hope you are getting the updated value on parent page in OnClientClose method and now want to set the RadTextBox value. Since you are using RadControls for ASP.NET AJAX version, you have to use $find() method in order to get the RadTextBox client side object and use the ' set_value ' method to set the text. Checkout the following documentation which describes important clientside methods of RadTextBox.
    Client-Side Basics
    RadTextBox Client Object

    -Shinu.
  3. Lynn
    Lynn avatar
    186 posts
    Member since:
    Sep 2006

    Posted 03 Nov 2009 Link to this post

    Shinu,

    Please disregard the text below the separator line (=========), although I believe there are issues with the documentation and with your suggestion because I could get none of it work properly.

    I did finally fix this problem myself through the use of the following script in the parent window:
                function OnClientClose(oWnd, args) {  
                    //get the transferred arguments  
                    var arg = args.get_argument();  
                    if (arg) {  
                        var cityName = arg.cityName;  
                        var seldate = arg.selDate;  
                        var screenName;  
                        screenName = document.getElementById("<%= MyScreenName.ClientID %>");  
                        screenName.value = cityName;  
                        screenName.set_displayvalue = cityName;  
                        var a1;  
                        var a2;  
                        a1 = document.getElementById("<%= MyScreenName.ClientID %>" + "_text");  
                        a1.value = cityName;  
                    }  
                }  
     
    As with one of the previous examples, I apologize for the confusion caused by variable names, etc.  This is a work in progress that was started from an example and then I have made changes one line at a time until I functionally had what I needed.  The "secret" in getting this to work was getting access to two (2) screen controls: the RadTextBox internal value represented above by document.getElementById("<%= MyScreenName.ClientID %>");  and it's displayed value represented above by document.getElementById("<%= MyScreenName.ClientID %>" + "_text");  .   
    Basically, I had to obtain addressability to both of these values and set the value of both for the entire solution to work correctly.  Oh, I should add that this solution is working on a parent page that uses a Master Page.

    I did find the basics of the second part of this solution (the use of the _text value) in another Forum item here on Telerik's web site.  But the examples in the documentation which show the use of "set_value" and "get_value" instead of the use of "value" did not work at all, and the use of the "$find" function instead of the "getElementById" did not work at all either.

    =====================================================================================================

    Thank you for trying to help, but unfortunately I could not get your suggestion to improve the situation...In fact, when using the "$find" functionality I couldn't the appropriate value set at all.  I should note that the page in question is using a Master Page.

    I'll do something really simple twice -- once with "$find" and once with the "document.getElementById" that I was using.

    EXAMPLE A -- $find
    The code used in this example is shown below.  The variable cityName is the value coming back from the RadWindow.  screenName is the RadTextBox on the parent window.
            function OnClientClose(oWnd, args)  
             {  
                //get the transferred arguments  
                var arg = args.get_argument();  
                if (arg) {  
                    var cityName = arg.cityName;  
                    var seldate = arg.selDate;  
                    alert("RadWindow value=" + cityName);  
                    var screenName;  
                    screenName = $find("<%= MyScreenName.ClientID %>");  
                    screenName.set_value = cityName;  
                    alert("RadTextBox value=" & screenName.get_value);  
                }  
            }  
     
    The resulting screen shots are:
    RadWindowA1 - After displaying the RadWindow;
    RadWindowA2 - After changing the value in the RadWindow from Bill to Jack (the first alert in the code above);
    RadWindowA3 - After changing the value in the RadWindow from Bill to Jack (the second alert in the code above).  As you can see, even the alert display doesn't display a value, it displays something entirely different.
    RadWindowA4 - After the second alert in the above code runs.  As you can see, the text box value has not changed to Jack.

    EXAMPLE B -- document.getElementById
    The code used in this example is shown below.
            function OnClientClose(oWnd, args)  
             {  
                //get the transferred arguments  
                var arg = args.get_argument();  
                if (arg) {  
                    var cityName = arg.cityName;  
                    var seldate = arg.selDate;  
                    alert("RadWindow value=" + cityName);  
                    var screenName;  
                    screenName = document.getElementById("<%= MyScreenName.ClientID %>");  
                    screenName.value = cityName;  
                    alert("RadTextBox value=" & screenName.get_value);  
                }  
            }  
     
    The resulting screen shots are:
    RadWindowB1 - After displaying the RadWindow;
    RadWindowB2 - After changing the value in the RadWindow from Bill to Jack (the first alert in the code above);
    RadWindowB3 - After changing the value in the RadWindow from Bill to Jack (the second alert in the code above).  As you can see, the RadTextBox value has been changed.
    RadWindowB4 - After the second alert in the above code runs.  As you can see, the text box DISPLAYED value has not changed to Jack.
    RadWindowB5 - After clicking the mouse inside the RadTextBox, the correct value is now displayed.

    If you can specifically tell me what I am doing wrong, I would be more than happy to change and run these same tests again.  I actually hope I have the code wrong, because otherwise this doesn't work the way your documentation says it does.  In fact, in the examples above, I have shown that the $find does not work correctly, and the get_value and set_value also do not work.

    Any help you can give me would be most appreciated!  I need to get this working.

    Thanks!



Back to Top