Rich Hopkins
Rich Hopkins

Reputation: 1891

How can I call a method after a Blazor Select is populated with its data?

In Blazor, I am populating a Select control with a simple List. I have the @onchange event working, but trying to figure out how to trigger a method call upon the list being loaded into the Select.

<select @onloadeddata=@SelectLoaded
        @onchange=@SelectChanged
        id="clientSelect"
        class="col-md-2">
  @foreach (var client in ClientList)
  {
    <option value="@client">@client</option>
  }
</select>

Is there an event on the Select that I can use? I've tried all of the ones that seem logical, but they don't seem to do the trick.

Upvotes: 0

Views: 376

Answers (1)

Mayur Ekbote
Mayur Ekbote

Reputation: 2080

You can call SelectLoaded when your select data (Presumably Client list?) is fetched, generally in the OnInitializedAsync - but it depends on your component.

In blazor server, the server does all the data loading etc and only sends the diffed HTML nodes to the browser script. The browser script is devoid of any component logic. Unlike JS based application, there is no client side data loading as such in a practical sense.

Upvotes: 1

Related Questions