razorpage .net6
davut5 opened this issue · comments
1- i installed package.
2-add builder.services. and in index page add using CurrieTechnologies.Razor.SweetAlert2;
3- how can I use basically show message.
public void OnPostSave()
{
Swal.FireAsync("Hello world!");
}
Swal does not exist in the current context. :(
Do you have this towards the top of your .razor
file?
@inject SweetAlertService Swal;
I added top of the index.cshtml. but give me reference error.. :(
It needs to go at the top of whichever .razor
file is using it. So wherever your OnPostSave()
call is written, it needs to be in that file.
I'll try to do a minimal replication and see what's going on there.
oh ok thank you. I think you put some sample. for Blazor, for Razorpage etc.
I have the same issue. Did you already find a solution?
I think I found the issue. I did not read the the title of the issue carefully enough.
I believe this library does not suite your use case. This is a library is only intended to work with Blazor applications (WASM or Server) , not with Razor Pages in a traditional ASP.NET web application.
Blazor is a front-end framework, and the code in this library runs on the front-end. Razor Pages are, instead, a way of templating server-generated pages.
I'll admit I have limited familiarity with Razor Pages, although I do believe there is a way to render Blazor components inside of them. Still this library doesn't offer any Blazor components. Just a Blazor services.
I will look into the possibility of SweetAlert being added to a RazorPage using this library, but for now, you'll want to use the main JS version of the library in the client section of your application.