Timeline for Is there a way to make disabled HTML elements not register Blazor events?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 12, 2022 at 22:13 | history | edited | Giancarlo Sierra | CC BY-SA 4.0 |
added 1 character in body
|
Apr 12, 2022 at 16:23 | history | edited | Giancarlo Sierra | CC BY-SA 4.0 |
added 557 characters in body
|
Apr 12, 2022 at 16:08 | comment | added | Giancarlo Sierra | Not a worry, just a question. I wonder if there is another way. If there is no other way besides controlling the events, then perhaps it could be a way to improve the framework. It's not about a single event, it's a repetitive pattern in general; I provided a simple example to explain this. | |
Apr 12, 2022 at 7:23 | answer | added | MrC aka Shaun Curtis | timeline score: 1 | |
Apr 12, 2022 at 1:48 | comment | added | Bennyboy1973 | 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. | |
Apr 12, 2022 at 1:31 | comment | added | Giancarlo Sierra | 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. | |
Apr 12, 2022 at 0:58 | comment | added | Bennyboy1973 |
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.
|
|
Apr 12, 2022 at 0:36 | comment | added | Dai | "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. | |
Apr 12, 2022 at 0:35 | comment | added | Dai | w3schools.com is not authoritative, btw. | |
Apr 12, 2022 at 0:31 | history | asked | Giancarlo Sierra | CC BY-SA 4.0 |