Hi,
If I have the following :
<CardHeader Title="blabla" SubTitle="test" ImageUrl="@aURL" />
Is there a way to provide the control with an alternative url if the picture is not found ?
Regards,
@using Syncfusion.Blazor.Cards
<SfCard ID="SecondCard">
<CardHeader Title="Harrisburg Keith" SubTitle="Title" ImageUrl="@aURL" />
<CardContent Content="Hi, I'm creative graphic design for print, new media based in Edenbridge" />
<CardFooter>
<CardFooterContent>
<table>
<tr>
<td> <div class="e-icons ChatIcon"></div></td>
<td> <div class="e-icons StarIcon"></div></td>
<td> <div class="e-icons AlarmIcon"></div></td>
</tr>
</table>
</CardFooterContent>
</CardFooter>
</SfCard>
@code {
//Invalid URL
public string aURL { get; set; } = "images/cards/football.png";
protected override async Task OnInitializedAsync()
{
if (!(Uri.TryCreate(aURL, UriKind.Absolute, out Uri uriResult) && uriResult.Scheme == Uri.UriSchemeHttps))
{
}
}
}
|
Hi,
I tried your solution and I could not get it to work, that section :
Uri.TryCreate(aURL, UriKind.Absolute, out Uri uriResult)
Works in my case even if the url returns 404
like so :
What could have been possible maybe is to allow for a bit of flexibility like so:
background-image: url(https://broken_picture.jpg),url("https://via.placeholder.com/300x300?text=Failed To Load");
When setting the ImageUrl, but I don't know if that's possible ?
@using Syncfusion.Blazor.Cards
@using System.Net.Http;
@using System.Threading.Tasks;
<SfCard ID="SecondCard">
<CardHeader Title="Harrisburg Keith" SubTitle="Title" ImageUrl="@aURL" />
<CardContent Content="Hi, I'm creative graphic design for print, new media based in Edenbridge" />
<CardFooter>
<CardFooterContent>
<table>
<tr>
<td> <div class="e-icons ChatIcon"></div></td>
<td> <div class="e-icons StarIcon"></div></td>
<td> <div class="e-icons AlarmIcon"></div></td>
</tr>
</table>
</CardFooterContent>
</CardFooter>
</SfCard>
@code {
//Invalid URL
public HttpClient client = new HttpClient();
protected override async Task OnInitializedAsync()
{
try
{
HttpResponseMessage response = await client.GetAsync(aURL);
}
catch
{
}
}
} |
That works thanks !
--Nicolas