- Visual Studio 2012 or later.
Steps to use Sweet Alert:
Open Visual Studio and create a new empty web Application in Visual C#.
Go to Solution Explorer, right-click the project file and click Add -> web Form
Add the code below in header Section of web Form
Open Solution Explorer, then right-click the project and click .
Click the Browse tab and search for Sweet Alert and install the SweetAlert.Base library. After Successfully install open WebForm. open solution explorer and open Scripts folder you can find sweetalert.min,js file drag and drop in header section. Now open styles Folder you can find sweetalert.css file drag and drop in header section.
Add 4 button in Body of web form. (success ,info ,warning ,error).
Paste the Code below in Button Click Event.
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "swal('Good job!', 'You clicked Success button!', 'success')",true);
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "swal('Information!', 'You clicked Info button!', 'info')", true);
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "swal('Warning!', 'You clicked Warning button!', 'warning')", true);
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "swal('Error!', 'You clicked Error button!', 'error')", true);
for more information you can read Sweet Alert guide.
Watch a full video to learn how to use sweet alert in .Net webform in Visual Studio.
Thank you for reading this article. Leave a comment if you have any question about this article. Please don’t forget to subscribe our official YouTube Channel RashiCode