Skip to main content

Call Methods

To call methods, use JavaScript API. For example, you have a Popup control:

@(Html.DevExtreme().Popup()
    .ID("popup")
)

This control appears on the page after its show() method is called. The code below demonstrates how to call this method.

$("#popup").dxPopup("show");

Note

To access a client widget instance in JavaScript, add the dx prefix to the widget name, for example, dxPopup.

You can put the provided code in any JavaScript constructions and execute it, for example, when a user clicks a button…

@* ... *@
@(Html.DevExtreme().Button()
    .OnClick("showPopup")
)
<script>
    function showPopup() {
        $("#popup").dxPopup("show");
    }
</script>

… or once your page is ready.

// ...
<script>
    $(showPopup);

    function showPopup() {
        $("#popup").dxPopup("show");
    }
</script>

If the called method accepts arguments, pass them after the method’s name. For example, the following code calls the Popup control’s toggle(showing) method with true as the argument.

$("#popup").dxPopup("toggle", true);

For more information, see DevExtreme API Reference.