Integrate Mosparo with Blazor Web App #401
|
Hey all I'm having trouble integrating mosparo with my Blazor Web App (Rendermode Interactive). EDIT My setup
The problemSince I am using Blazor Web App with Server Interactive (Documentation), my website is fully rendererd on the server. The server has a realtime connection to the frontend UI, which handles basically everything, all UI and HTTP events etc. As far as i know, in this mode there are no HTTP Post calls in this setup, since all values from a from are accessible over this realtime connection. And there lies my problem. My understanding is that mosparo relies on Post Calls (please correct me, if I am wrong about this) to receive the final values of a form and to verify them. I can render the form with the visible mosparo box with no issues, but I can't send the formdata to mosparo after the form is completed. Is it even possible to use mosparo fully in this environment or should I switch to a blazor web app version, which is rendered on the client side and uses traditional Post calls for its forms? Thank you for your thoughts My form`<MudForm ` |
Replies: 2 comments 7 replies
|
Hi @TabalugaDrache (Thank you for the childhood memories :) ) Thank you very much for your question. I don't know Blazor Web App/MudBlazor, and before I set up a test environment, let's check some simple things:
Thank you very much for your feedback. Kind regards, |
|
Alright, thank you very much for your response and clarification. Now the problem is clear to me. Here is what you should do:
<MudTextField
name="SubmitToken"
InputId="submit-token"
@bind-Value="@this.KontaktWerte.SubmitToken"
For="@(() => this.KontaktWerte.SubmitToken)"
InputType="InputType.Hidden"
Required
/>
<MudTextField
name="ValidationToken"
InputId="validation-token"
@bind-Value="@this.KontaktWerte.ValidationToken"
For="@(() => this.KontaktWerte.ValidationToken)"
InputType="InputType.Hidden"
Required
/>(I have no idea about the attributes you may additionally need)
var m = new mosparo(
'mosparo-box',
'<host>',
'<uuid>',
'<publicKey>',
{
// other options...
onCheckForm: function (result) {
if (!result) { // The form contains spam
return;
}
let submitToken = document.getElementById('submit-token'); // The hidden input field from your form, you may have to adjust the ID
let validationToken = document.getElementById('validation-token'); // The hidden input field from your form, you may have to adjust the ID
submitToken.value = m.submitTokenElement.value;
validationToken.value = m.validationTokenElement.value;
submitToken.dispatchEvent(new Event('change')); // The important part
validationToken.dispatchEvent(new Event('change')); // The important part
},
}
);(I took the method from here: https://stackoverflow.com/questions/71436693/how-to-set-a-blazor-input-control-via-javascript)
Please let me know if that works or if I miss something. If it doesn't work, I will create my own example using MudBlazor to understand the problem better. Kind regards, |
Hi @TabalugaDrache
Alright, thank you very much for your response and clarification. Now the problem is clear to me.
Here is what you should do:
(I have no idea abou…