How do I alert a string of Text in a Routine Adapter Class Using Console.WriteLineInBlazor
Hello Syncfusion,
As show below in the piece of code, I would like the highlighted text to be thrown on my browser when the condition in the if statement is met, but in Blazor, nothing is being alerted by the Console.WriteLine .
How can I achieve this using Syncfusion.
I have attached the whole insert method from which the code snippet was extracted incase you might need to refer to it.
Thank You
var exist = dbContext.District.FirstOrDefault(o => o.RegionCode == val.RegionCode && o.DistrictName == val.DistrictName);
if (exist != null)
{
result = "This District Arleady Exists!";
Console.WriteLine(result);
}
Attachment: Insert_Method_ade7b949.rar
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
RS
Renjith Singh Rajendran
Syncfusion Team
January 5, 2021 12:33 PM UTC
Hi Ssekamatte,
Greetings from Syncfusion support.
Based on this scenario, you can use Microsoft JSInterop feature to display the text in the browser console window, as like the suggestion provided in the below general documentation,
You can inject the IJSRuntime into CustomAdaptor class by using constructor injection, and use the IJSRuntime to display the needed text in browser console. We are also attaching a sample for your reference, please download the sample from the link below,
Please refer the below highlighted codes and use these codes in your application,
|
public class CustomAdaptor : DataAdaptor
{
public IJSRuntime jsRuntime { get; set; }
public CustomAdaptor(IJSRuntime jSRuntime)
{
jsRuntime = jSRuntime;
}
public override object Read(DataManagerRequest dm, string key = null)
{
...
}
public override object Insert(DataManager dm, object value, string key)
{
...
string result = "This District Arleady Exists!";
jsRuntime.InvokeAsync<string>("console.log", result);
return value;
}
}
[Startup.cs]
|
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran
Marked as answer
SJ
Ssekamatte James
January 6, 2021 06:32 AM UTC
Thank You Very Much. This worked for me
RS
Renjith Singh Rajendran
Syncfusion Team
January 6, 2021 02:15 PM UTC
Hi Ssekamatte,
Thanks for your update.
We are glad to hear that the provided suggestion helped you in achieving this requirement.
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
SJ Ssekamatte James
- Jan 4, 2021 02:18 PM UTC
- Jan 6, 2021 02:15 PM UTC