Upload with parameters

Hello. :slight_smile: I am trying to use the RadzenUpload in a form so the user can specify the parameters and then upload them to a database. This is the code I did:

public async Task prepEditBrigadists()
{
var result = await DialogService.OpenAsync("Editar brigadista", ds =>
@

<RadzenNumeric @bind-Value="@idEmployee" />


<RadzenDropDown @bind-Value="areaId" Data="areas" TextProperty="@nameof(areasBrigades.AreaName)" ValueProperty="@nameof(areasBrigades.AreaId)"
Change="@(async()=>await OnSelectionChanged())" Style=@($"box-shadow: 0 0 10px 2px {selectedAreaColor}") />


<RadzenUpload @ref="upload" Auto="false" Multiple="false" Accept="image/*" Url=@($"edit/{idEmployee}/{idArea}/{u.UserTress}/{plantId}") class="w-100" />

<RadzenButton ButtonStyle="ButtonStyle.Primary" Text="Añadir" Click=@(args => upload.Upload()) />

);
}

I do not know if is because the radzen upload and then the url are rendered at the same time but as the areaId and idEmployee are 0 at first, whenever I hit the button with these values changed, in the controllers those values are still 0. I do not know if there is a better way to achieve this or if it is possible. I want the values of the url to change as I change them in the RadzenNumeric and the DropDown. I initially tried with only upload a photo with one predefined parameter and worked perfectly but with this scenario it has been a bit chaotic.

I am using Blazor Web App in .net 8

Thank you so much for your support.

You can attach Radzen.Blazor.csproj to your application to debug if Url is changed properly.

I just could do what I wanted with the upload. Not the way I wanted but it works. I now have the question of how I can access or actually receive the response code from the controller?

Hi @LuisL,

You can try the Complete event.

<RadzenUpload Complete=@OnComplete ... />
@code {
    void OnComplete(UploadCompleteEventArgs args)
    {
        console.Log($"Server response: {args.RawResponse}");
    }
}
</RadzenUpload>
}
1 Like