Search code examples
c#asp.netrazordevextreme

How to add mouseenter listener to control?


I am creating HTML controls with this kind of code

@(Html.DevExtreme().Button()
    .ID("submitButton")
    .Text("Submit")
    .Icon("check")
    .Type(ButtonType.Success)
)

How can I add a mouse enter listener?

There exist .OnInitialized and .OnContentReady, also .OnKeyDown .OnInput etc., but no .OnMouseEnter for example.

'SelectBoxBuilder' does not contain a definition for 'OnMouseEnter' and no accessible extension method ... could be found

How can I call some javascript function for mouseover or mouseenter? Generating some equivalent of the HTML

<input onmouseenter="myFunction()">

I can probably use .OnInitialized("addMouseEnter") but is there a cleaner way to do it with less in-betweens?


Solution

  • I found out about .ElementAttr which can be used to add element attributes manually.

        .ElementAttr("onmouseenter", "myFunction()")`
    

    works for this case