Change the target name RadzenUpload

Hi Friends,

In RadzenUpload I want to change the target file name. But I could not succeed in the passing parameter to UploadControl. When I try to set URL property with querystring option (such as upload/single?${somevariable}), the component returns an error (do not support complex content).

I checked out the posts and samples.

The sample named "Upload with additional parameter" can be a solution. But I could not figure out how can fill the {1} in this sample.

Could you help me?
Thanks for your support,
KB

1 Like

Hi, we updated the demo to show how to use a parameter in the Url property.

1 Like

Hi @korchev

I checked out your sample again and this is exactly what I had been tried before. But I can't succeed. I can't pass the values to the controller.

Here is my basic code.

[HttpPost("upload/{Id}")]
public IActionResult Post(IFormFile file, int Id)
{
    try
    {
        Pages.AppSurveySetup appSurveySetup = new Pages.AppSurveySetup();
        Stream stream = file.OpenReadStream();
        var path = $"{Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")}\\UserFiles\\f_{Id}.xlsx";
        FileStream fs = System.IO.File.Create(path);
        stream.CopyToAsync(fs);
        stream.Close();
        fs.Close();

        return StatusCode(200);
    }
    catch (Exception ex)
    {
        return StatusCode(500, ex.Message);
    }
}

}

The "Id" is a page variable and predefined. Id returns 0 in this code. When I check OnProgress method the variable value is being correct.

Everything seems correct from my side. But I missed something.

Need help,

Thanks for your time,
KB

Hi @korchev ,

I found the reason.
When I declare the Url property in the Radzen, I had been used the default notation such as upload/{Id}. In this case, Radzen does not create a proper format in the generated code.

But when I wrote @($"upload/{Id}") line in the Url property everything is solved.

I'm learning the Radzen point of view. Which code is generated directly and which one is pre-processed must be known.

Thanks,

1 Like

@koksal.basar thanks a lot for posting your solution. I ran into the same issue.
Url property for the RadzenUpload component within Radzen with the content /upload/single/${parameters.Id} caused
error RZ9986: Component attributes do not support complex content (mixed C# and markup). Attribute: 'Url', text: '/upload/single/Id'
The following parameter value worked for passing a parameter
${"/upload/single/" + parameters.Id}

1 Like