I tricked the RadzenTextBox into allowing Control Characters that a Prevent Default-ed from showing in the field.
I have a small form with, among others, a quantity field. and 2 radio buttons for X Full and X Partial In the application I'm replacing. This is a volume scanning operation so the operator scans and then enters the quantity and presses "+" if the radio button needs to change to full or:"-" to change to Partial as a time-saving shortcut.
I came across this syncfusion page and it worked, however, only in this manner:
I actually made it work, but I can't build it for I get RZ10010 errors.
Severity
Code
Description
Project
File
Line
Suppression State
Error (active)
RZ10010
The component parameter 'onkeydown' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'onkeydown' is generated by the '@onkeydown:preventDefault' directive attribute.
Now comes the kicker, even though the error was generated, Hot Reload rebuilt the app with the added @onkeydown:preventdefault and after the screen refreshed, it worked as I'd hoped. I guess it just went ahead and added it to html.
This resulting in the behavior that I am seeking.
Is it possible that the RZ10010 is a little too tight. It appears that allowing @onkeydown:PreventDefault =(Boolean) works for stripping out characters.
Yes sir, I apologize for being unclear. I'm asking if there's any way to make the following code not generate an error? Using the followng creates a RZ10010 error in the build. The second line below causes the error. I actually would like to be able to use this construct..
onKeyDown checks for a "+'": or a :"-" if true sets isPreventKey = true.
The preventDefautl is observeed and the characters are prevented from being typed into the field.
I want to process a function for + and - and have them not appear in whatever text field the user is in. + and - will change a radio button.
I forced this to work by adding the prevent default line while running then hitting hot reload. It generated the working code even though the error was shown. It did produce the desired functinality. I just can't build it.
I hope that's more clear. If not I can probably send a project to check.
thank you
The perfect answer would be to be able to strip these 2 control characters out of input at a form level rather than for each control individually. Do you think that's possible? Perhaps using EditForm instead of RadzenTempateForm? I tried just hanging it on a containing
You can easily remove those characters from the input before saving the data to your database. We don't have a different solution other the the already suggested one.
It's hard to get the same response in a web form that they get in WinForms.
As you said its a Blazor issue, the Input statement generates the same error.
I may have to try integrating some javascript. Thank you for your help.
I have created a working, self-contained example solution to prevent "+" and "-" characters from appearing. yet still be able to act on them as control characters, solving the need expressed in this thread. Below are three examples in code, a small parent form, the razor form component and a snippet of JavaScript.
You can press + or - in either field and the Radio button will change to 'full' for '+' and 'empty' for '-'.
Parent Form:
@page "/ittools/plusminus"
<h3>Plus/Minus</h3>
<div class="row">
<div class="col">
<PlusMinusForm />
</div>
<div class="col">
<p>
The idea is you press + to change to 'full' and - to change to 'empty'
</p>
</div>
</div>
Below is the Component Form Code, with an example of RadzenTextBox and InputText: