1
<script>
    function OnInit(s, e) {
        var input = s.GetInputElement();
        var MyValue = TextBox.GetValue(); // Question is here
        ASPxClientUtils.AttachEventToElement(input, "click", function (event) {
            s.SetText("");
        });
    }
        function onLostFocus(s, e) {
            if (s.GetText() == '')
                s.SetSelectedIndex(0);
        }
</script>

I want to use "MyValue " in onLostFocus function.

How can i get "MyValue" in onLostFocus function?

Any help will be appreciated.

1 Answer 1

4

You have to change the variable scope so its available for both functions.:

<script>
    var MyValue; // define the variable outside the function
    function OnInit(s, e) {
        var input = s.GetInputElement();
        MyValue = TextBox.GetValue();
        ASPxClientUtils.AttachEventToElement(input, "click", function (event) {
            s.SetText("");
        });
    }
    function onLostFocus(s, e) {
        if (s.GetText() == '')
            s.SetSelectedIndex(0);
    }
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.