Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • w3schools.com is not authoritative, btw.
    – Dai
    Commented Apr 12, 2022 at 0:35
  • "However, this is not very safe since a user can edit the HTML document quickly to remove the disabled attribute from the HTML element." - this is a non-issue (and you should never trust software running on a remote client, even if you wrote it). You should always validate all user-input, including Blazor events: just ignore events if your server-side code says that input/control should be disabled.
    – Dai
    Commented Apr 12, 2022 at 0:36
  • 1
    Just add a check for the bool value in your event handler, and skip your handling logic if the component is supposed to be disabled. Commented Apr 12, 2022 at 0:58
  • Yes, it's easy to control the event handlers and add validations, but events are being fired anyways, could that be avoided so no events are linked to the element? Since elements can be linked to multiple events, you would have to control each of those. The idea would be to save unneeded resources and simplify things, server side it could be SignalR messages for example. Commented Apr 12, 2022 at 1:31
  • 2
    You're worried about a case in which someone will hack the page to enable a control, thereby triggering a Blazor event, and that the 1 line it takes to check that the event SHOULD be triggered would introduce an inefficiency? If you've spent more than 10 seconds thinking about this, then you've lost far more than the total CPU time that this "inefficiency" will cost if you run your site under high load for the next 100 years. You need to think about more important issues-- like a clean UI and well-organized data structures. Commented Apr 12, 2022 at 1:48