I'm using the Radzen TextArea to have a user enter some text and afterwards they can click a button to Submit this text.
I have my Submit button disabled for as long as TextArea doesn't have any value.
As per my experience and also noticed in the TextArea demo, a user needs to click outside the TextArea for it to register the changes.
Is there a way to prevent that. I want my user to be able to submit the text without him needing to click twice.
No, currently this is not possible. Instead of disabling the submit button you can use validation. Clicking the button will blur the textbox and sync the value.
I'm having the same issue in that the last field a user changes before hitting the Submit button is not having its new value updated to the database unless they tab away.
I can't always use validation, for example they may just correct the spelling of a name. Is there any way I can prevent this from happening when the Submit button is clicked?
Clicking the submit button should always blur the text thus update the textbox value. We are not aware of a case when this won't happen. If you have such a scenario please let us know how to reproduce it.
Edit a record, change the value in a bound text field.
Without clicking away from text field, click the Submit button. Notify message is shown and DataBase is updated correctly.
Alter text field value again.
Repeat step 2. The Notify message is not displayed this time, and the database is not updated.
Without making any further changes, click the Submit button again. This time the Notify message does appear, and the database is updated.
If you repeat the same steps, but this time change the value in, for example, two text boxes, leaving the cursor in the second, only the first text box's value is updated to the database.
I can't reproduce the described issue by editing this demo. Here is what I observe:
The value i
The fact that the notification message doesn't show is strange. Even if the value were the same it should have shown. I suspect an exception is being thrown and is caught in the empty catch() {} block. What happens when you debug the application? Can you try logging the exception:
Ok, I added the suggested code, but it's never triggered. I've since tried taking the Submit= option away from the RadzenTemplateForm tag and instead set a Click option on the Submit button tag. Finally, I've added a notification message at the very start of the Submit code block.
On the first 'Save' on the page, the record is correctly updated even if I leave cursor in the field).
On the second and subsequent 'Save', if the modified field is not tabbed away from, clicking the submit button has no effect - my code block is not triggered (all is well, however, if I do tab away).
Do you mean the Click event of the button or the Submit event of the form? If you handle the Click event of the button it will bypass validation and always execute your handler. Not getting the code to run is very weird and should be related to RadzenTextBox at all. By the way is that code in a dialog by any chance?
Can you reproduce this behavior in the linked demo? It is pretty similar to your scenario and already provides logging support.
I get the same issue whether I use the Submit event of the form or the Click event of the button - I have tried both ways.
No code is in a dialog.
I can't reproduce the behaviour in your linked demo.
Weirdly, if I change nothing at all on the page, the Submit event is triggered, it's only if I change something and do not tab out of the field. In that specific cirumstance, the Submit event is not triggered until the button is clicked twice.
I must admit this is very odd. Could you try something for me? Remove all the code from the Submit handler but the notifications - comment everything else. Does the problem still happen? You can also temporarily remove all validators and basically all other components apart from the offending textbox.
Thats probably good news - it means that the RadzenTextBox registers the change (which the original thread was about). I am still not sure what could be causing the erratic behavior that you see though. You can try adding back your original code (start with the components first). Please let me know if you find which bit makes it fail.
Could you also try removing the error boundary and bringing back your code? And remove the try catch block. If the code in the submit handler is causing the problem there should be an exception. I am also baffled by this issue.
I discovered that the code was just stopping/hanging when I tried to create a new instance of a respository object, which I was doing in order to retrieve the updated record to 'refresh' the page (specifically, to have available the record's current timestamp).
So, I'm reworking my DB access approach.
Thanks for the input, both of you. As you will be only too well aware, I am very new to Blazor, Radzen, and web programming in general.
You should avoid async void at all costs as it has a lot of drawbacks. For example exceptions that happen in such methods can bring the whole application down.
Before reworking your code I recommend just changing the return type of the method to async Task and seeing what would happen. There is a chance that an exception will be thrown this time with more meaningful information.