What is the equivalent of Attributes property in dotvvm

For the asp.net web forms server controls, we have the “Attributes” property using which we can assign the control attributes in code-behind. Do we have an equivalent property for dotvvm controls or can you suggest a workaround to achieve this.
Below is an example usage in the aspx page code behind for your reference,
btnGetName.Attributes.Add(“onclick”, “javascript:getName(this);return false;”);

It depends on a use case.

  • In DotVVM pages, you don’t usually access the controls from the viewmodel (it’s possible, but you don’t want to do it). Instead, you set viewmodel properties, and then use data-binding to bind the values to attributes: <dot:SomeControl someattribute=”{value: ValueFromViewModel}” />
  • If you create your own controls and want to generate some HTML with attributes, there are multiple ways - the easiest is new HtmlGenericControl().SetAttribute(“attr”, value).
  • If you need to call JS functions from buttons in the page, you can check out the [JS directive feature](Overview | DotVVM Documentation).

Hi @tomasherceg - Thanks for the feedback.

We are currently trying to migrate a web forms application to dotvvm, and as part of it, we are trying to reuse the code in the aspx code behind files as much as possible. So in one of the pages we have the scenario where the attributes of a control are added programmatically based on different conditions, so the number of attributes added to the controls ‘Attributes’ property will vary for different conditions.
So is there a way to mimic the same behavior in dotvvm.

We tried creating an Attributes viewmodel property of type Dictionary<string, string>, and tried to mimic this scenario, but we could not find an equivalent dotvvm control property to assign this viewmodel property. We tried the below, but it did not work.

<dot:TextBox id=“{{value: Control.ID}}”
Text=“{value: Control.Text}”
Attributes=“{value: Control.Attributes}”
/>