Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
How to call blazor onclick method with static render mode

How to call onclick method while rendering component as a static html? I mean, is there any workarounds in JavaScript?

@(await Html.RenderComponentAsync<Awesome>(RenderMode.Static))

And the Awesome.razor

<h3>@name</h3>

<button @onclick="@(() => name = name.ToUpper())">Upper case me</button>

@code {
    string name = "Mr. Blazor";
}

While using ServerPrerendered it seems to work because oninitialize method is fire, but again onclick doesn't work.

@(await Html.RenderComponentAsync<Awesome>(RenderMode.ServerPrerendered))
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Like the docs say:

Static : Renders the component into static HTML

That means an @onclick will never work, nor anything else in written in C#.

is there any workarounds in JavaScript?

JavaScript will still work, use onclick (without the @). But that won't let you use this name variable.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!