Hi,
I am using Combo Box with TValue of a class type, everything works fine until I updated from version 18 to 19.
If I don't bind the Combo Box value with a property of the same type with TValue, but when I use @bind-value, it keeps throwing the error saying:
Unexpected character encountered while parsing value: C. Path '', line 0, position 0.
Please advice what is the proper way to bind the complex object value to the Combo Box.
I also attach the sample code and screen shot of full error messages as reference.
Thanks.
Hi Price,
Attached below is the working sample project that reproduced the problem that I am facing.
In my case, I am using the complex object, and I believe that is what causing the problems, but again, everything was working fine until I update the to version 19.
// There is Logo object nested inside school object,
// without the logo property, everything works fine.
// with Logo property exist:
// 1. When the logo is null, it gives error:
// NullReferenceException
// 2. When the Logo is is assigned value, it gives error:
// Unexpected character encountered while parsing value: B. Path '', line 0, position 0.
Apart from the above problem, there is another problem with the popup is not closing and the combo box crashing, after reselecting new option consecutively for a few times, and when using Filter event there are sometimes 2 popups overlapping.
Thanks beforehand for your time and support.
Attachment: BlazorServerApp5.0_18805b0f.zip
|
public DateTimeOffset ModifiedDate
{
get
{
modifiedDate = DateTimeOffset.Now;
return modifiedDate;
}
set { modifiedDate = value; }
} |
|
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BlazorServerApp5._0.Data
{
public class OwnService
{
public async Task<List<School>> GetDataAsync()
{
FileInformation logo = new FileInformation()
{
Id = "715e27e8da16940bdc7a21b2",
Name = "Logo1.png",
Path = "https://test.com/Logo1.png"
};
// When the logo is null, it gives error:
// NullReferenceException
// When the Logo is is assigned value, it gives error:
// Unexpected character encountered while parsing value: B. Path '', line 0, position 0.
List<School> Values = new List<School> { };
Values.Add(new School()
{
Id = "615e27e8da16940bdc7a21b3",
Code = "I1",
Name = "Item 1",
Logo = logo,
StageSets = new string[] { "Stage", "Certificate" },
CreatedDate = new DateTimeOffset(DateTime.Now),
ModifiedDate = new DateTimeOffset(DateTime.Now)
});
return await Task.FromResult(Values);
}
}
public class School
{
public string Id { get; set; }
public FileInformation Logo { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public string[] StageSets { get; set; }
private DateTimeOffset? createdDate;
public DateTimeOffset CreatedDate
{
get { return createdDate ?? DateTimeOffset.Now; }
set { createdDate = value; }
}
private DateTimeOffset? modifiedDate;
public DateTimeOffset ModifiedDate
{
get
{
return modifiedDate ?? DateTimeOffset.Now;
}
set { modifiedDate = value; }
}
}
}
|